Fixes #645: CDbConnection now throws CDbException when failed to open DB connection instead of failing with a warning

This commit is contained in:
Alexander Makarov
2013-01-08 02:12:58 +04:00
parent f4534cb476
commit d1cf0527ce
2 changed files with 7 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ Version 1.1.14 work in progress
- Bug #150: Fixed CWidget was not switching between view paths when using themes (antoncpu)
- Bug #1915: CDataProviderIterator: fixed init in case of disabled pagination (antoncpu)
- Enh #1847: Added COutputCache::varyByLanguage to generate separate cache for different languages (Obramko)
- Chg #645: CDbConnection now throws CDbException when failed to open DB connection instead of failing with a warning (kidol, eirikhm, samdark)
- Chg #1891: Changed order of methods in models generated by Gii and yiic, added better description of search method (hijarian, samdark)
- New #1785: Added CPasswordHelper (tom--)

View File

@@ -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;
}
/**