1 | <?php |
||
7 | class PdoConnection implements ConnectionInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var \PDO |
||
11 | */ |
||
12 | private $pdo; |
||
13 | |||
14 | private $dsn; |
||
15 | |||
16 | 9 | public function __construct($dsn) |
|
20 | |||
21 | 9 | public function query($query) |
|
22 | { |
||
23 | 9 | $this->initialize(); |
|
24 | |||
25 | try { |
||
26 | 6 | $stmt = $this->pdo->query($query); |
|
27 | 6 | } catch (\PDOException $e) { |
|
28 | throw new ConnectionException($e->getMessage(), 0, $e); |
||
29 | } |
||
30 | |||
31 | 6 | return $stmt->fetchAll(\PDO::FETCH_ASSOC); |
|
32 | } |
||
33 | |||
34 | 3 | public function multiQuery($query, array $resultSetNames = array()) |
|
54 | |||
55 | 3 | public function exec($query) |
|
56 | { |
||
57 | 3 | $this->initialize(); |
|
58 | |||
59 | try { |
||
60 | 3 | return $this->pdo->exec($query); |
|
61 | } catch (\PDOException $e) { |
||
62 | throw new ConnectionException($e->getMessage(), 0, $e); |
||
63 | } |
||
64 | } |
||
65 | |||
66 | public function quote($value) |
||
76 | |||
77 | 9 | protected function initialize() |
|
87 | |||
88 | public function checkConnection() |
||
89 | { |
||
96 | } |
||
97 |