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