forked from apaoww/yii2-oci8
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOci8DbConnection.php
49 lines (39 loc) · 1.4 KB
/
Oci8DbConnection.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
<?php
namespace bogdik\oci8;
require_once('pdo/Oci8PDO.php');
use yii;
use yii\db\Connection;
class Oci8DbConnection extends Connection
{
public $pdoClass = 'Oci8PDO';
public $schemaMap = ['oci8'=>'bogdik\oci8\Schema'];
/**
* Creates the PDO instance.
* When some functionalities are missing in the pdo driver, we may use
* an adapter class to provides them.
* @return PDO the pdo instance
* @throws $e
*/
protected function createPdoInstance()
{
if (!empty($this->charset)) {
Yii::trace('Error: OciDbConnection::$charset has been set to `' . $this->charset . '` in your config. The property is only used for MySQL and PostgreSQL databases. If you want to set the charset in Oracle to UTF8, add the following to the end of your OciDbConnection::$connectionString: ;charset=AL32UTF8;', 'ext.oci8Pdo.OciDbConnection');
}
try {
Yii::trace('Opening Oracle connection', 'ext.oci8Pdo.OciDbConnection');
$pdoClass = parent::createPdoInstance();
} catch (PDOException $e) {
throw $e;
}
return $pdoClass;
}
/**
* Closes the currently active Oracle DB connection.
* It does nothing if the connection is already closed.
*/
public function close()
{
Yii::trace('Closing Oracle connection', 'ext.oci8Pdo.OciDbConnection');
parent::close();
}
}