| Total Complexity | 6 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Coverage | 57.14% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class Connection extends PDOConnection implements \Doctrine\DBAL\Driver\Connection |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * {@inheritDoc} |
||
| 19 | 3 | */ |
|
| 20 | public function lastInsertId(?string $name = null) : string |
||
| 21 | 3 | { |
|
| 22 | 2 | if ($name === null) { |
|
| 23 | return parent::lastInsertId($name); |
||
| 24 | } |
||
| 25 | 1 | ||
| 26 | 1 | $stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?'); |
|
| 27 | $stmt->execute([$name]); |
||
| 28 | 1 | ||
| 29 | $result = $stmt->fetchColumn(); |
||
| 30 | |||
| 31 | if ($result === false) { |
||
| 32 | // WIP regarding exceptions, see: |
||
| 33 | // https://github.com/doctrine/dbal/pull/3335#discussion_r234381175 |
||
| 34 | 8 | throw new class ('No sequence with name "' . $name . '" found.') extends AbstractDriverException {}; |
|
| 35 | } |
||
| 36 | 8 | ||
| 37 | return (string) $result; |
||
| 38 | } |
||
| 39 | 8 | ||
| 40 | /** |
||
| 41 | * {@inheritDoc} |
||
| 42 | */ |
||
| 43 | 8 | public function quote($value, $type = ParameterType::STRING) : string |
|
| 44 | { |
||
| 45 | $val = parent::quote($value, $type); |
||
| 46 | |||
| 47 | // Fix for a driver version terminating all values with null byte |
||
| 48 | if (strpos($val, "\0") !== false) { |
||
| 49 | 236 | $val = substr($val, 0, -1); |
|
| 50 | } |
||
| 51 | 236 | ||
| 52 | return $val; |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * {@inheritDoc} |
||
| 57 | */ |
||
| 58 | protected function createStatement(\PDOStatement $stmt) : PDOStatement |
||
| 61 | } |
||
| 62 | } |
||
| 63 |