1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Oracle; |
6
|
|
|
|
7
|
|
|
use PDO; |
8
|
|
|
use Yiisoft\Db\Connection\Connection as AbstractConnection; |
9
|
|
|
use Yiisoft\Db\Cache\QueryCache; |
10
|
|
|
use Yiisoft\Db\Cache\SchemaCache; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Database connection class prefilled for ORACLE Server. |
14
|
|
|
*/ |
15
|
164 |
|
final class Connection extends AbstractConnection |
16
|
|
|
{ |
17
|
164 |
|
private QueryCache $queryCache; |
18
|
164 |
|
private SchemaCache $schemaCache; |
19
|
|
|
|
20
|
|
|
public function __construct(string $dsn, QueryCache $queryCache, SchemaCache $schemaCache) |
21
|
164 |
|
{ |
22
|
|
|
$this->queryCache = $queryCache; |
23
|
164 |
|
$this->schemaCache = $schemaCache; |
24
|
|
|
|
25
|
|
|
parent::__construct($dsn, $queryCache); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function createCommand(?string $sql = null, array $params = []): Command |
29
|
|
|
{ |
30
|
|
|
if ($sql !== null) { |
31
|
305 |
|
$sql = $this->quoteSql($sql); |
32
|
|
|
} |
33
|
305 |
|
|
34
|
|
|
$command = new Command($this, $this->queryCache, $sql); |
35
|
|
|
|
36
|
204 |
|
if ($this->logger !== null) { |
37
|
|
|
$command->setLogger($this->logger); |
38
|
204 |
|
} |
39
|
|
|
|
40
|
|
|
if ($this->profiler !== null) { |
41
|
204 |
|
$command->setProfiler($this->profiler); |
42
|
|
|
} |
43
|
204 |
|
|
44
|
|
|
return $command->bindValues($params); |
45
|
204 |
|
} |
46
|
204 |
|
|
47
|
|
|
/** |
48
|
204 |
|
* Returns the schema information for the database opened by this connection. |
49
|
|
|
* |
50
|
|
|
* @return Schema the schema information for the database opened by this connection. |
51
|
|
|
*/ |
52
|
204 |
|
public function getSchema(): Schema |
53
|
|
|
{ |
54
|
|
|
return new Schema($this, $this->schemaCache); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
protected function createPdoInstance(): PDO |
58
|
|
|
{ |
59
|
7 |
|
return new PDO($this->getDsn(), $this->getUsername(), $this->getPassword(), $this->getAttributes()); |
60
|
|
|
} |
61
|
7 |
|
|
62
|
|
|
protected function initConnection(): void |
63
|
|
|
{ |
64
|
|
|
$pdo = $this->getPDO(); |
65
|
|
|
|
66
|
|
|
if ($pdo !== null) { |
67
|
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
68
|
|
|
|
69
|
|
|
if ($this->getEmulatePrepare() !== null && constant('PDO::ATTR_EMULATE_PREPARES')) { |
70
|
|
|
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, $this->getEmulatePrepare()); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Returns the name of the DB driver. |
77
|
|
|
* |
78
|
|
|
* @return string name of the DB driver |
79
|
|
|
*/ |
80
|
|
|
public function getDriverName(): string |
81
|
|
|
{ |
82
|
|
|
return 'oci'; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|