1 | <?php |
||
20 | abstract class PDOConnection implements Connection, PDOExceptionMapper, Logger |
||
21 | { |
||
22 | /** |
||
23 | * @var PDO |
||
24 | */ |
||
25 | private $pdo; |
||
26 | |||
27 | /** |
||
28 | * @var TypeProvider |
||
29 | */ |
||
30 | private $types; |
||
31 | |||
32 | /** |
||
33 | * @var int number of nested calls to transact() |
||
34 | * |
||
35 | * @see transact() |
||
36 | */ |
||
37 | private $transaction_level = 0; |
||
38 | |||
39 | /** |
||
40 | * @var bool net result of nested calls to transact() |
||
41 | * |
||
42 | * @see transact() |
||
43 | */ |
||
44 | private $transaction_result; |
||
45 | |||
46 | /** |
||
47 | * @var Logger[] |
||
48 | */ |
||
49 | private $loggers = []; |
||
50 | |||
51 | /** |
||
52 | * To avoid duplicating dependencies, you should use DatabaseContainer::createPDOConnection() |
||
53 | * rather than calling this constructor directly. |
||
54 | * |
||
55 | * @param PDO $pdo |
||
56 | * @param TypeProvider $types |
||
57 | */ |
||
58 | 1 | public function __construct(PDO $pdo, TypeProvider $types) |
|
63 | |||
64 | /** |
||
65 | * @inheritdoc |
||
66 | */ |
||
67 | 1 | public function prepare(Statement $statement) |
|
93 | |||
94 | /** |
||
95 | * @inheritdoc |
||
96 | */ |
||
97 | 1 | public function fetch(Statement $statement, $batch_size = 1000) |
|
109 | |||
110 | /** |
||
111 | * @inheritdoc |
||
112 | */ |
||
113 | 1 | public function execute(Statement $statement) |
|
121 | |||
122 | /** |
||
123 | * @inheritdoc |
||
124 | */ |
||
125 | 1 | public function count(Countable $statement) |
|
129 | |||
130 | /** |
||
131 | * @inheritdoc |
||
132 | */ |
||
133 | 1 | public function transact(callable $func) |
|
180 | |||
181 | /** |
||
182 | * Internally expand SQL placeholders (for array-types) |
||
183 | * |
||
184 | * @param string $sql SQL with placeholders |
||
185 | * @param array $params placeholder name/value pairs |
||
186 | * |
||
187 | * @return string SQL with expanded placeholders |
||
188 | */ |
||
189 | 1 | private function expandPlaceholders($sql, array $params) |
|
209 | |||
210 | /** |
||
211 | * @param string|null $sequence_name auto-sequence name (or NULL for e.g. MySQL which supports only one auto-key) |
||
212 | * |
||
213 | * @return int|string |
||
214 | */ |
||
215 | public function lastInsertId($sequence_name = null) |
||
223 | |||
224 | /** |
||
225 | * @inheritdoc |
||
226 | */ |
||
227 | 1 | public function addLogger(Logger $logger) |
|
231 | |||
232 | /** |
||
233 | * @inheritdoc |
||
234 | */ |
||
235 | 1 | public function logQuery($sql, $params, $time_msec) |
|
241 | } |
||
242 |