mirror of
https://github.com/yiisoft/yii.git
synced 2026-03-21 07:26:53 +01:00
Fixes #645: CDbConnection now throws CDbException when failed to open DB connection instead of failing with a warning
This commit is contained in:
@@ -406,6 +406,7 @@ class CDbConnection extends CApplicationComponent
|
||||
* Creates the PDO instance.
|
||||
* When some functionalities are missing in the pdo driver, we may use
|
||||
* an adapter class to provides them.
|
||||
* @throws CDbException when failed to open DB connection
|
||||
* @return PDO the pdo instance
|
||||
*/
|
||||
protected function createPdoInstance()
|
||||
@@ -419,8 +420,12 @@ class CDbConnection extends CApplicationComponent
|
||||
elseif($driver==='sqlsrv')
|
||||
$pdoClass='CMssqlSqlsrvPdoAdapter';
|
||||
}
|
||||
return new $pdoClass($this->connectionString,$this->username,
|
||||
@$instance=new $pdoClass($this->connectionString,$this->username,
|
||||
$this->password,$this->_attributes);
|
||||
if(!$instance)
|
||||
throw new CDbException(Yii::t('yii', 'CDbConnection failed to open the DB connection'));
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user