doctrine /
dbal
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Doctrine\DBAL\Driver\PDOSqlsrv; |
||
| 6 | |||
| 7 | use Doctrine\DBAL\Driver\PDOConnection; |
||
| 8 | use Doctrine\DBAL\Driver\PDOStatement; |
||
| 9 | use function strpos; |
||
| 10 | use function substr; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Sqlsrv Connection implementation. |
||
| 14 | */ |
||
| 15 | class Connection extends PDOConnection |
||
| 16 | { |
||
| 17 | 3 | public function lastInsertId(?string $name = null) : string |
|
| 18 | { |
||
| 19 | 3 | if ($name === null) { |
|
| 20 | 2 | return parent::lastInsertId($name); |
|
| 21 | } |
||
| 22 | |||
| 23 | 1 | $stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?'); |
|
| 24 | 1 | $stmt->execute([$name]); |
|
| 25 | |||
| 26 | 1 | return $stmt->fetchColumn(); |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 27 | } |
||
| 28 | |||
| 29 | 5 | public function quote(string $input) : string |
|
| 30 | { |
||
| 31 | 5 | $val = parent::quote($input); |
|
| 32 | |||
| 33 | // Fix for a driver version terminating all values with null byte |
||
| 34 | 5 | if (strpos($val, "\0") !== false) { |
|
| 35 | $val = substr($val, 0, -1); |
||
| 36 | } |
||
| 37 | |||
| 38 | 5 | return $val; |
|
| 39 | } |
||
| 40 | |||
| 41 | 321 | protected function createStatement(\PDOStatement $stmt) : PDOStatement |
|
| 42 | { |
||
| 43 | 321 | return new Statement($stmt); |
|
| 44 | } |
||
| 45 | } |
||
| 46 |