1 | <?php |
||
2 | /** |
||
3 | * @link http://is74.ru/ |
||
4 | * @copyright Copyright (c) 2014 Интерсвязь |
||
5 | */ |
||
6 | |||
7 | namespace Intersvyaz\ExtDb; |
||
8 | |||
9 | /** |
||
10 | * @inheritdoc |
||
11 | */ |
||
12 | class Connection extends \yii\db\Connection |
||
13 | { |
||
14 | /** |
||
15 | * @event [[yii\base\Event|Event]] an event that is triggered before a DB connection is established |
||
16 | */ |
||
17 | const EVENT_BEFORE_OPEN = 'beforeOpen'; |
||
18 | |||
19 | /** |
||
20 | * @inheritdoc |
||
21 | */ |
||
22 | protected function createPdoInstance() |
||
23 | { |
||
24 | $this->trigger(self::EVENT_BEFORE_OPEN); |
||
25 | return parent::createPdoInstance(); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @inheritdoc |
||
30 | */ |
||
31 | 1 | public function createCommand($sql = null, $params = []) |
|
32 | { |
||
33 | 1 | $this->open(); |
|
34 | 1 | $command = new Command([ |
|
35 | 1 | 'db' => $this, |
|
36 | 1 | ]); |
|
37 | |||
38 | 1 | $command->setSql($sql, $params); |
|
39 | |||
40 | 1 | return $command->bindValues($params); |
|
41 | } |
||
42 | } |
||
43 |