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 | * @inheritdoc |
||
67 | */ |
||
68 | 1 | public function prepare(Statement $statement) |
|
94 | |||
95 | /** |
||
96 | * @inheritdoc |
||
97 | */ |
||
98 | 1 | public function fetch(Statement $statement, $batch_size = 1000) |
|
115 | |||
116 | /** |
||
117 | * @inheritdoc |
||
118 | */ |
||
119 | 1 | public function execute(Statement $statement) |
|
127 | |||
128 | /** |
||
129 | * @inheritdoc |
||
130 | */ |
||
131 | 1 | public function count(Countable $statement) |
|
135 | |||
136 | /** |
||
137 | * @inheritdoc |
||
138 | */ |
||
139 | 1 | public function transact(callable $func) |
|
186 | |||
187 | /** |
||
188 | * Internally expand SQL placeholders (for array-types) |
||
189 | * |
||
190 | * @param string $sql SQL with placeholders |
||
191 | * @param array $params placeholder name/value pairs |
||
192 | * |
||
193 | * @return string SQL with expanded placeholders |
||
194 | */ |
||
195 | 1 | private function expandPlaceholders($sql, array $params) |
|
215 | |||
216 | /** |
||
217 | * @param string|null $sequence_name auto-sequence name (or NULL for e.g. MySQL which supports only one auto-key) |
||
218 | * |
||
219 | * @return int|string |
||
220 | */ |
||
221 | public function lastInsertId($sequence_name = null) |
||
229 | |||
230 | /** |
||
231 | * @inheritdoc |
||
232 | */ |
||
233 | 1 | public function addLogger(Logger $logger) |
|
237 | |||
238 | /** |
||
239 | * @inheritdoc |
||
240 | */ |
||
241 | 1 | public function logQuery($sql, $params, $time_msec) |
|
247 | } |
||
248 |