From 1cbfcb195587ebbc9142dde4539469d928b671a0 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 15 Jan 2013 20:52:29 -0500 Subject: [PATCH] clean up --- framework/db/Command.php | 2 -- framework/db/Connection.php | 11 +++++------ framework/db/Transaction.php | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/framework/db/Command.php b/framework/db/Command.php index 7c83839..6861024 100644 --- a/framework/db/Command.php +++ b/framework/db/Command.php @@ -9,8 +9,6 @@ namespace yii\db; -use yii\db\Exception; - /** * Command represents a SQL statement to be executed against a database. * diff --git a/framework/db/Connection.php b/framework/db/Connection.php index e211f6c..2b9530e 100644 --- a/framework/db/Connection.php +++ b/framework/db/Connection.php @@ -9,7 +9,6 @@ namespace yii\db; -use yii\db\Exception; use yii\base\BadConfigException; /** @@ -334,7 +333,7 @@ class Connection extends \yii\base\ApplicationComponent try { \Yii::trace('Opening DB connection: ' . $this->dsn, __CLASS__); $this->pdo = $this->createPdoInstance(); - $this->initConnection($this->pdo); + $this->initConnection(); } catch (\PDOException $e) { \Yii::error("Failed to open DB connection ({$this->dsn}): " . $e->getMessage(), __CLASS__); @@ -380,8 +379,9 @@ class Connection extends \yii\base\ApplicationComponent /** * Initializes the DB connection. * This method is invoked right after the DB connection is established. - * The default implementation sets the database [[charset]] and executes SQLs specified - * in [[initSQLs]]. + * The default implementation turns on `PDO::ATTR_EMULATE_PREPARES` + * if [[emulatePrepare]] is true, and sets the database [[charset]] if it is not empty. + * It then triggers an [[afterOpen]] event. */ protected function initConnection() { @@ -408,8 +408,7 @@ class Connection extends \yii\base\ApplicationComponent 'connection' => $this, 'sql' => $sql, )); - $command->bindValues($params); - return $command; + return $command->bindValues($params); } /** diff --git a/framework/db/Transaction.php b/framework/db/Transaction.php index c1c7f0d..4870a08 100644 --- a/framework/db/Transaction.php +++ b/framework/db/Transaction.php @@ -9,7 +9,6 @@ namespace yii\db; -use yii\db\Exception; use yii\base\BadConfigException; /**