1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Oracle\PDO; |
6
|
|
|
|
7
|
|
|
use PDO; |
8
|
|
|
use Yiisoft\Db\Cache\QueryCache; |
9
|
|
|
use Yiisoft\Db\Cache\SchemaCache; |
10
|
|
|
use Yiisoft\Db\Connection\ConnectionPDO; |
11
|
|
|
use Yiisoft\Db\Driver\PDODriver; |
12
|
|
|
use Yiisoft\Db\Exception\Exception; |
13
|
|
|
use Yiisoft\Db\Exception\InvalidConfigException; |
14
|
|
|
use Yiisoft\Db\Oracle\Quoter; |
15
|
|
|
use Yiisoft\Db\Query\Query; |
16
|
|
|
use Yiisoft\Db\Query\QueryBuilderInterface; |
|
|
|
|
17
|
|
|
use Yiisoft\Db\Schema\QuoterInterface; |
18
|
|
|
use Yiisoft\Db\Schema\SchemaInterface; |
19
|
|
|
use Yiisoft\Db\Transaction\TransactionInterface; |
20
|
|
|
|
21
|
|
|
use function constant; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Database connection class prefilled for Oracle SQL Server. |
25
|
|
|
* The class Connection represents a connection to a database via [PDO](https://secure.php.net/manual/en/book.pdo.php). |
26
|
|
|
*/ |
27
|
|
|
final class ConnectionPDOOracle extends ConnectionPDO |
28
|
|
|
{ |
29
|
|
|
private ?Query $query = null; |
30
|
|
|
|
31
|
381 |
|
public function __construct( |
32
|
|
|
protected PDODriver $driver, |
33
|
|
|
protected QueryCache $queryCache, |
34
|
|
|
protected SchemaCache $schemaCache |
35
|
|
|
) { |
36
|
381 |
|
parent::__construct($queryCache); |
37
|
|
|
} |
38
|
|
|
|
39
|
336 |
|
public function createCommand(?string $sql = null, array $params = []): CommandPDOOracle |
40
|
|
|
{ |
41
|
336 |
|
$command = new CommandPDOOracle($this, $this->queryCache); |
42
|
|
|
|
43
|
336 |
|
if ($sql !== null) { |
44
|
174 |
|
$command->setSql($sql); |
45
|
|
|
} |
46
|
|
|
|
47
|
336 |
|
if ($this->logger !== null) { |
48
|
336 |
|
$command->setLogger($this->logger); |
49
|
|
|
} |
50
|
|
|
|
51
|
336 |
|
if ($this->profiler !== null) { |
52
|
336 |
|
$command->setProfiler($this->profiler); |
53
|
|
|
} |
54
|
|
|
|
55
|
336 |
|
return $command->bindValues($params); |
56
|
|
|
} |
57
|
|
|
|
58
|
8 |
|
public function createTransaction(): TransactionInterface |
59
|
|
|
{ |
60
|
8 |
|
return new TransactionPDOOracle($this); |
61
|
|
|
} |
62
|
|
|
|
63
|
7 |
|
public function getDriverName(): string |
64
|
|
|
{ |
65
|
7 |
|
return 'oci'; |
66
|
|
|
} |
67
|
|
|
|
68
|
336 |
|
public function getQuery(): Query |
69
|
|
|
{ |
70
|
336 |
|
if ($this->query === null) { |
71
|
336 |
|
$this->query = new Query($this); |
72
|
|
|
} |
73
|
|
|
|
74
|
336 |
|
return $this->query; |
|
|
|
|
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @throws Exception|InvalidConfigException |
79
|
|
|
*/ |
80
|
336 |
|
public function getQueryBuilder(): QueryBuilderInterface |
81
|
|
|
{ |
82
|
336 |
|
if ($this->queryBuilder === null) { |
83
|
336 |
|
$this->queryBuilder = new QueryBuilderPDOOracle( |
84
|
336 |
|
$this->createCommand(), |
85
|
336 |
|
$this->getQuery(), |
86
|
336 |
|
$this->getQuoter(), |
87
|
336 |
|
$this->getSchema(), |
88
|
|
|
); |
89
|
|
|
} |
90
|
|
|
|
91
|
336 |
|
return $this->queryBuilder; |
|
|
|
|
92
|
|
|
} |
93
|
|
|
|
94
|
349 |
|
public function getQuoter(): QuoterInterface |
95
|
|
|
{ |
96
|
349 |
|
if ($this->quoter === null) { |
97
|
349 |
|
$this->quoter = new Quoter('"', '"', $this->getTablePrefix()); |
98
|
|
|
} |
99
|
|
|
|
100
|
349 |
|
return $this->quoter; |
|
|
|
|
101
|
|
|
} |
102
|
|
|
|
103
|
350 |
|
public function getSchema(): SchemaInterface |
104
|
|
|
{ |
105
|
350 |
|
if ($this->schema === null) { |
106
|
350 |
|
$this->schema = new SchemaPDOOracle($this, $this->schemaCache); |
107
|
|
|
} |
108
|
|
|
|
109
|
350 |
|
return $this->schema; |
|
|
|
|
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Initializes the DB connection. |
114
|
|
|
* |
115
|
|
|
* This method is invoked right after the DB connection is established. |
116
|
|
|
* |
117
|
|
|
* The default implementation turns on `PDO::ATTR_EMULATE_PREPARES`. |
118
|
|
|
* |
119
|
|
|
* if {@see emulatePrepare} is true, and sets the database {@see charset} if it is not empty. |
120
|
|
|
* |
121
|
|
|
* It then triggers an {@see EVENT_AFTER_OPEN} event. |
122
|
|
|
*/ |
123
|
177 |
|
protected function initConnection(): void |
124
|
|
|
{ |
125
|
177 |
|
$this->pdo = $this->driver->createConnection(); |
126
|
177 |
|
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
127
|
|
|
|
128
|
177 |
|
if ($this->getEmulatePrepare() !== null && constant('PDO::ATTR_EMULATE_PREPARES')) { |
129
|
|
|
$this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, $this->getEmulatePrepare()); |
130
|
|
|
} |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|
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