/
Driver.php
66 lines (58 loc) · 1.61 KB
/
Driver.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Driver\PDOOracle;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\AbstractOracleDriver;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\Driver\PDOException;
use PDO;
/**
* PDO Oracle driver.
*
* WARNING: This driver gives us segfaults in our testsuites on CLOB and other
* stuff. PDO Oracle is not maintained by Oracle or anyone in the PHP community,
* which leads us to the recommendation to use the "oci8" driver to connect
* to Oracle instead.
*/
class Driver extends AbstractOracleDriver
{
/**
* {@inheritdoc}
*/
public function connect(
array $params,
string $username = '',
string $password = '',
array $driverOptions = []
) : Connection {
if (! empty($params['persistent'])) {
$driverOptions[PDO::ATTR_PERSISTENT] = true;
}
try {
return new PDOConnection(
$this->constructPdoDsn($params),
$username,
$password,
$driverOptions
);
} catch (PDOException $e) {
throw DBALException::driverException($this, $e);
}
}
/**
* Constructs the Oracle PDO DSN.
*
* @param mixed[] $params
*
* @return string The DSN.
*/
private function constructPdoDsn(array $params) : string
{
$dsn = 'oci:dbname=' . $this->getEasyConnectString($params);
if (isset($params['charset'])) {
$dsn .= ';charset=' . $params['charset'];
}
return $dsn;
}
}