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
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Driver\OCI8;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\AbstractOracleDriver;
use Doctrine\DBAL\Driver\Connection;
use const OCI_DEFAULT;
/**
* A Doctrine DBAL driver for the Oracle OCI8 PHP extensions.
*/
class Driver extends AbstractOracleDriver
{
/**
* {@inheritdoc}
*/
public function connect(
array $params,
string $username = '',
string $password = '',
array $driverOptions = []
) : Connection {
try {
return new OCI8Connection(
$username,
$password,
$this->_constructDsn($params),
$params['charset'] ?? '',
$params['sessionMode'] ?? OCI_DEFAULT,
$params['persistent'] ?? false
);
} catch (OCI8Exception $e) {
throw DBALException::driverException($this, $e);
}
}
/**
* Constructs the Oracle DSN.
*
* @param mixed[] $params
*
* @return string The DSN.
*/
protected function _constructDsn(array $params) : string
{
return $this->getEasyConnectString($params);
}
}