Completed
Pull Request — master (#3759)
by Benjamin
131:22 queued 67:31
created

Connection::createStatement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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
    /**
18
     * {@inheritDoc}
19 42
     */
20
    public function getSequenceNumber(string $name) : string
21 42
    {
22 42
        $stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?');
23 42
        $stmt->execute([$name]);
24
25
        return $stmt->fetchColumn();
26
    }
27
28 3
    /**
29
     * {@inheritDoc}
30 3
     */
31 3
    public function quote(string $input) : string
32
    {
33
        $val = parent::quote($input);
34 2
35 2
        // Fix for a driver version terminating all values with null byte
36
        if (strpos($val, "\0") !== false) {
37 2
            $val = substr($val, 0, -1);
38
        }
39
40
        return $val;
41
    }
42
43 31
    /**
44
     * {@inheritDoc}
45 31
     */
46
    protected function createStatement(\PDOStatement $stmt) : PDOStatement
47
    {
48 31
        return new Statement($stmt);
49
    }
50
}
51