Hello,
I’m trying to elegantly handle a case where the database server has been stopped.
I’m getting this error:
PDO::__construct(): [2002] Connection refused (trying to connect via tcp://127.0.0.1:3306)
395 protected function createPdoInstance()
396 {
397 $pdoClass=$this->pdoClass;
398 if(($pos=strpos($this->connectionString,':'))!==false)
399 {
400 $driver=strtolower(substr($this->connectionString,0,$pos));
401 if($driver==='mssql' || $driver==='dblib' || $driver==='sqlsrv')
402 $pdoClass='CMssqlPdoAdapter';
403 }
404 return new $pdoClass($this->connectionString,$this->username,
405 $this->password,$this->_attributes);
406 }
With a stack trace as:
/Library/WebServer/Documents/yii/framework/db/CDbConnection.php(405): PDO->__construct("mysql:host=127.0.0.1;dbname=e", "per", "prs", array())
#1 /Library/WebServer/Documents/yii/framework/db/CDbConnection.php(356): CDbConnection->createPdoInstance()
#2 /Library/WebServer/Documents/yii/framework/db/CDbConnection.php(313): CDbConnection->open()
#3 /Library/WebServer/Documents/yii/framework/db/CDbConnection.php(291): CDbConnection->setActive(true)
#4 /Library/WebServer/Documents/yii/framework/base/CModule.php(372): CDbConnection->init()
#5 /Library/WebServer/Documents/yii/framework/base/CModule.php(86): CModule->getComponent("db")
#6 /Library/WebServer/Documents/cours/protected/components/dao/AuthenticationDao.php(20): CModule->__get("db")
Any ideas would be greatly appreciated.
- Glenn