forked from intersvyaz/yii-extended-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DbConnection.php
56 lines (51 loc) · 1.54 KB
/
DbConnection.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
<?php
namespace Intersvyaz\ExtendedDb;
/**
* DBConnection
* Расширение стандартного класса соединения с БД.
* Позволяет биндить и раскомментировать код в SQL запросах.
*/
class DbConnection extends \CDbConnection
{
/**
* @var array mapping between PDO driver and schema class name.
* A schema class can be specified using path alias.
*/
public $driverMap=array(
'cubrid'=>'CCubridSchema', // CUBRID
'pgsql'=> '\Intersvyaz\ExtendedDb\PgsqlSchema', // PostgreSQL
'mysqli'=>'CMysqlSchema', // MySQL
'mysql'=>'CMysqlSchema', // MySQL,MariaDB
'sqlite'=>'CSqliteSchema', // sqlite 3
'sqlite2'=>'CSqliteSchema', // sqlite 2
'mssql'=>'CMssqlSchema', // Mssql driver on windows hosts
'dblib'=>'CMssqlSchema', // dblib drivers on linux (and maybe others os) hosts
'sqlsrv'=>'CMssqlSchema', // Mssql
'oci'=>'COciSchema', // Oracle driver
);
/**
* @inheritdoc
*/
protected function open()
{
parent::open();
if($this->hasEventHandler('onAfterOpen'))
$this->onAfterOpen(new \CEvent($this));
}
/**
* This event is raised after the connection open
* @param \CEvent $event
*/
public function onAfterOpen(\CEvent $event)
{
$this->raiseEvent('onAfterOpen', $event);
}
/**
* @inheritdoc
*/
public function createCommand($sql = null, $params = null)
{
$this->setActive(true);
return new DbCommand($this, $sql, $params);
}
}