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, array $mappers = []) |
|
110 | |||
111 | /** |
||
112 | * @inheritdoc |
||
113 | */ |
||
114 | 1 | public function execute(Statement $statement) |
|
122 | |||
123 | /** |
||
124 | * @inheritdoc |
||
125 | */ |
||
126 | 1 | public function count(Countable $statement) |
|
130 | |||
131 | /** |
||
132 | * @inheritdoc |
||
133 | */ |
||
134 | 1 | public function transact(callable $func) |
|
181 | |||
182 | /** |
||
183 | * Internally expand SQL placeholders (for array-types) |
||
184 | * |
||
185 | * @param string $sql SQL with placeholders |
||
186 | * @param array $params placeholder name/value pairs |
||
187 | * |
||
188 | * @return string SQL with expanded placeholders |
||
189 | */ |
||
190 | 1 | private function expandPlaceholders($sql, array $params) |
|
210 | |||
211 | /** |
||
212 | * @param string|null $sequence_name auto-sequence name (or NULL for e.g. MySQL which supports only one auto-key) |
||
213 | * |
||
214 | * @return int|string |
||
215 | */ |
||
216 | public function lastInsertId($sequence_name = null) |
||
224 | |||
225 | 1 | public function addLogger(Logger $logger) |
|
229 | |||
230 | 1 | function logQuery($sql, $params, $time_msec) |
|
236 | |||
237 | } |
||
238 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.