1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Mssql\PDO; |
6
|
|
|
|
7
|
|
|
use PDO; |
8
|
|
|
use Yiisoft\Db\Command\CommandInterface; |
9
|
|
|
use Yiisoft\Db\Connection\ConnectionPDO; |
10
|
|
|
use Yiisoft\Db\Exception\Exception; |
11
|
|
|
use Yiisoft\Db\Exception\InvalidConfigException; |
12
|
|
|
use Yiisoft\Db\Mssql\Quoter; |
13
|
|
|
use Yiisoft\Db\Query\QueryBuilderInterface; |
|
|
|
|
14
|
|
|
use Yiisoft\Db\Schema\QuoterInterface; |
15
|
|
|
use Yiisoft\Db\Schema\SchemaInterface; |
16
|
|
|
use Yiisoft\Db\Transaction\TransactionInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Database connection class prefilled for Microsoft SQL Server. |
20
|
|
|
* The class Connection represents a connection to a database via [PDO](https://secure.php.net/manual/en/book.pdo.php). |
21
|
|
|
*/ |
22
|
|
|
final class ConnectionPDOMssql extends ConnectionPDO |
23
|
|
|
{ |
24
|
377 |
|
public function createCommand(?string $sql = null, array $params = []): CommandInterface |
25
|
|
|
{ |
26
|
377 |
|
$command = new CommandPDOMssql($this, $this->queryCache); |
27
|
|
|
|
28
|
377 |
|
if ($sql !== null) { |
29
|
214 |
|
$command->setSql($sql); |
30
|
|
|
} |
31
|
|
|
|
32
|
377 |
|
if ($this->logger !== null) { |
33
|
377 |
|
$command->setLogger($this->logger); |
34
|
|
|
} |
35
|
|
|
|
36
|
377 |
|
if ($this->profiler !== null) { |
37
|
377 |
|
$command->setProfiler($this->profiler); |
38
|
|
|
} |
39
|
|
|
|
40
|
377 |
|
return $command->bindValues($params); |
41
|
|
|
} |
42
|
|
|
|
43
|
8 |
|
public function createTransaction(): TransactionInterface |
44
|
|
|
{ |
45
|
8 |
|
return new TransactionPDOMssql($this); |
46
|
|
|
} |
47
|
|
|
|
48
|
11 |
|
public function getDriverName(): string |
49
|
|
|
{ |
50
|
11 |
|
return 'sqlsrv'; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @throws Exception|InvalidConfigException |
55
|
|
|
*/ |
56
|
377 |
|
public function getQueryBuilder(): QueryBuilderInterface |
57
|
|
|
{ |
58
|
377 |
|
if ($this->queryBuilder === null) { |
59
|
377 |
|
$this->queryBuilder = new QueryBuilderPDOMssql( |
60
|
377 |
|
$this->createCommand(), |
61
|
377 |
|
$this->getQuoter(), |
62
|
377 |
|
$this->getSchema(), |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
377 |
|
return $this->queryBuilder; |
|
|
|
|
67
|
|
|
} |
68
|
|
|
|
69
|
398 |
|
public function getQuoter(): QuoterInterface |
70
|
|
|
{ |
71
|
398 |
|
if ($this->quoter === null) { |
72
|
398 |
|
$this->quoter = new Quoter(['[', ']'], ['[', ']'], $this->getTablePrefix()); |
73
|
|
|
} |
74
|
|
|
|
75
|
398 |
|
return $this->quoter; |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
380 |
|
public function getSchema(): SchemaInterface |
79
|
|
|
{ |
80
|
380 |
|
if ($this->schema === null) { |
81
|
380 |
|
$this->schema = new SchemaPDOMssql($this, $this->schemaCache); |
82
|
|
|
} |
83
|
|
|
|
84
|
380 |
|
return $this->schema; |
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Initializes the DB connection. |
89
|
|
|
* |
90
|
|
|
* This method is invoked right after the DB connection is established. |
91
|
|
|
* |
92
|
|
|
* The default implementation turns on `PDO::ATTR_EMULATE_PREPARES`. |
93
|
|
|
* |
94
|
|
|
* if {@see emulatePrepare} is true, and sets the database {@see charset} if it is not empty. |
95
|
|
|
* |
96
|
|
|
* It then triggers an {@see EVENT_AFTER_OPEN} event. |
97
|
|
|
*/ |
98
|
209 |
|
protected function initConnection(): void |
99
|
|
|
{ |
100
|
209 |
|
$this->pdo = $this->driver->createConnection(); |
101
|
209 |
|
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths