1 | <?php |
||
9 | class Pdo implements AdapterInterface |
||
10 | { |
||
11 | private $connection; |
||
12 | private $options; |
||
13 | |||
14 | /** |
||
15 | * @param Options $options |
||
16 | * @param \PDO $connection |
||
17 | */ |
||
18 | 128 | public function __construct(Options $options, \PDO $connection) |
|
23 | |||
24 | /** |
||
25 | * @return \PDO |
||
26 | */ |
||
27 | 114 | private function getConnection(): \PDO |
|
31 | |||
32 | /** |
||
33 | * @return Options |
||
34 | */ |
||
35 | 15 | public function getOptions(): Options |
|
39 | |||
40 | 35 | public function beginTransaction(): void |
|
45 | |||
46 | 18 | public function commitTransaction(): void |
|
51 | |||
52 | 18 | public function rollbackTransaction(): void |
|
57 | |||
58 | 35 | public function isInTransaction(): bool |
|
63 | |||
64 | 31 | public function canHandleNestedTransaction(): bool |
|
65 | { |
||
66 | 31 | return false; |
|
67 | } |
||
68 | |||
69 | 108 | public function quoteIdentifier(string $columnName): string |
|
73 | |||
74 | 15 | public function executeInsertSQL(string $sql, array $params = array()) |
|
75 | { |
||
76 | 15 | $options = $this->getOptions(); |
|
77 | 15 | $this->executeSQL($sql, $params); |
|
78 | |||
79 | 15 | if (array_key_exists($options->getIdColumnName(), $params)) { |
|
80 | 2 | return $params[$options->getIdColumnName()]; |
|
81 | } else { |
||
82 | 13 | if ('' != $options->getSequenceName()) { |
|
83 | 13 | $lastGeneratedValue = $this->getConnection() |
|
84 | 13 | ->lastInsertId($options->getSequenceName()); |
|
85 | } else { |
||
86 | $lastGeneratedValue = $this->getConnection() |
||
87 | ->lastInsertId(); |
||
88 | } |
||
89 | |||
90 | 13 | return $lastGeneratedValue; |
|
91 | } |
||
92 | } |
||
93 | |||
94 | 60 | public function executeSQL(string $sql, array $params = array()): void |
|
100 | |||
101 | 87 | public function executeSelectSQL(string $sql, array $params = array()): array |
|
109 | } |
||
110 |