diff --git a/framework/db/Command.php b/framework/db/Command.php index 928e114..0861b8d 100644 --- a/framework/db/Command.php +++ b/framework/db/Command.php @@ -134,7 +134,7 @@ class Command extends \yii\base\Component } catch (\Exception $e) { \Yii::error($e->getMessage() . "\nFailed to prepare SQL: $sql", __CLASS__); $errorInfo = $e instanceof \PDOException ? $e->errorInfo : null; - throw new Exception($e->getMessage(), (int)$e->getCode(), $errorInfo); + throw new Exception($e->getMessage(), $errorInfo, (int)$e->getCode()); } } } @@ -292,7 +292,7 @@ class Command extends \yii\base\Component \Yii::error("$message\nFailed to execute SQL: {$sql}{$paramLog}", __CLASS__); $errorInfo = $e instanceof \PDOException ? $e->errorInfo : null; - throw new Exception($message, (int)$e->getCode(), $errorInfo); + throw new Exception($message, $errorInfo, (int)$e->getCode()); } } @@ -431,7 +431,7 @@ class Command extends \yii\base\Component $message = $e->getMessage(); \Yii::error("$message\nCommand::$method() failed: {$sql}{$paramLog}", __CLASS__); $errorInfo = $e instanceof \PDOException ? $e->errorInfo : null; - throw new Exception($message, (int)$e->getCode(), $errorInfo); + throw new Exception($message, $errorInfo, (int)$e->getCode()); } } diff --git a/framework/db/Connection.php b/framework/db/Connection.php index cb294a8..40164a3 100644 --- a/framework/db/Connection.php +++ b/framework/db/Connection.php @@ -320,7 +320,7 @@ class Connection extends Component { if ($this->pdo === null) { if (empty($this->dsn)) { - throw new InvalidConfigException('Connection.dsn cannot be empty.'); + throw new InvalidConfigException('Connection::dsn cannot be empty.'); } try { \Yii::trace('Opening DB connection: ' . $this->dsn, __CLASS__); @@ -330,7 +330,7 @@ class Connection extends Component catch (\PDOException $e) { \Yii::error("Failed to open DB connection ({$this->dsn}): " . $e->getMessage(), __CLASS__); $message = YII_DEBUG ? 'Failed to open DB connection: ' . $e->getMessage() : 'Failed to open DB connection.'; - throw new Exception($message, (int)$e->getCode(), $e->errorInfo); + throw new Exception($message, $e->errorInfo, (int)$e->getCode()); } } } diff --git a/framework/db/Exception.php b/framework/db/Exception.php index 5f388fd..ad97b5a 100644 --- a/framework/db/Exception.php +++ b/framework/db/Exception.php @@ -24,13 +24,14 @@ class Exception extends \yii\base\Exception /** * Constructor. * @param string $message PDO error message - * @param integer $code PDO error code * @param mixed $errorInfo PDO error info + * @param integer $code PDO error code + * @param \Exception $previous The previous exception used for the exception chaining. */ - public function __construct($message, $code = 0, $errorInfo = null) + public function __construct($message, $errorInfo = null, $code = 0, \Exception $previous = null) { $this->errorInfo = $errorInfo; - parent::__construct($message, $code); + parent::__construct($message, $code, $previous); } /** diff --git a/framework/db/mysql/QueryBuilder.php b/framework/db/mysql/QueryBuilder.php index 1d2e2f1..a078b9a 100644 --- a/framework/db/mysql/QueryBuilder.php +++ b/framework/db/mysql/QueryBuilder.php @@ -52,7 +52,7 @@ class QueryBuilder extends \yii\db\QueryBuilder $quotedTable = $this->db->quoteTableName($table); $row = $this->db->createCommand('SHOW CREATE TABLE ' . $quotedTable)->queryRow(); if ($row === false) { - throw new Exception("Unable to find '$oldName' in table '$table'."); + throw new Exception("Unable to find column '$oldName' in table '$table'."); } if (isset($row['Create Table'])) { $sql = $row['Create Table'];