1 | <?php |
||
21 | abstract class PDOConnection implements Connection, PDOExceptionMapper, Logger |
||
22 | { |
||
23 | /** |
||
24 | * @var PDO |
||
25 | */ |
||
26 | private $pdo; |
||
27 | |||
28 | /** |
||
29 | * @var TypeProvider |
||
30 | */ |
||
31 | private $types; |
||
32 | |||
33 | /** |
||
34 | * @var int number of nested calls to transact() |
||
35 | * |
||
36 | * @see transact() |
||
37 | */ |
||
38 | private $transaction_level = 0; |
||
39 | |||
40 | /** |
||
41 | * @var bool net result of nested calls to transact() |
||
42 | * |
||
43 | * @see transact() |
||
44 | */ |
||
45 | private $transaction_result; |
||
46 | |||
47 | /** |
||
48 | * @var Logger[] |
||
49 | */ |
||
50 | private $loggers = []; |
||
51 | |||
52 | /** |
||
53 | * To avoid duplicating dependencies, you should use DatabaseContainer::createPDOConnection() |
||
54 | * rather than calling this constructor directly. |
||
55 | * |
||
56 | * @param PDO $pdo |
||
57 | * @param TypeProvider $types |
||
58 | */ |
||
59 | 1 | public function __construct(PDO $pdo, TypeProvider $types) |
|
64 | |||
65 | /** |
||
66 | * @return PDO the internal PDO connection object |
||
67 | */ |
||
68 | public function getPDO() |
||
72 | |||
73 | /** |
||
74 | * @inheritdoc |
||
75 | */ |
||
76 | 1 | public function prepare(Statement $statement) |
|
102 | |||
103 | /** |
||
104 | * @inheritdoc |
||
105 | */ |
||
106 | 1 | public function fetch(Statement $statement, $batch_size = 1000) |
|
118 | |||
119 | /** |
||
120 | * @inheritdoc |
||
121 | */ |
||
122 | 1 | public function execute(Statement $statement) |
|
130 | |||
131 | /** |
||
132 | * @inheritdoc |
||
133 | */ |
||
134 | 1 | public function count(Countable $statement) |
|
138 | |||
139 | /** |
||
140 | * @inheritdoc |
||
141 | */ |
||
142 | 1 | public function transact(callable $func) |
|
191 | |||
192 | /** |
||
193 | * Internally expand SQL placeholders (for array-types) |
||
194 | * |
||
195 | * @param string $sql SQL with placeholders |
||
196 | * @param array $params placeholder name/value pairs |
||
197 | * |
||
198 | * @return string SQL with expanded placeholders |
||
199 | */ |
||
200 | 1 | private function expandPlaceholders($sql, array $params) |
|
220 | |||
221 | /** |
||
222 | * @param string|null $sequence_name auto-sequence name (or NULL for e.g. MySQL which supports only one auto-key) |
||
223 | * |
||
224 | * @return int|string |
||
225 | */ |
||
226 | public function lastInsertId($sequence_name = null) |
||
234 | |||
235 | /** |
||
236 | * @inheritdoc |
||
237 | */ |
||
238 | 1 | public function addLogger(Logger $logger) |
|
242 | |||
243 | /** |
||
244 | * @inheritdoc |
||
245 | */ |
||
246 | 1 | public function logQuery($sql, $params, $time_msec) |
|
252 | } |
||
253 |