I've followed all the instructions in chapter 4 to create a test file for the database connection.
Here's the settings in 'main.php' :
'db'=>array( 'connectionString' => 'pgsql:host=localhost;port=5432;dbname=trackstar', 'username' => 'myusername', 'password' => 'mypassword' ),
The error is :
CDbException: CDbConnection failed to open the DB connection.
The strange thing is, i can connect to the database in the application. Inside 'protected/views/index.php' , i have :
try {
echo 'Connecting...<br/>';
$connection = Yii::app()->db; // (*)
echo ($connection ? 'Successful' : 'Failed');
}
catch(Exception $ex) {
echo $ex->getMessage();
}
It actually returns 'Successful'. Or i can replace (*) in the code above with
$connection = new CDbConnection('pgsql:host=localhost;port=5432;dbname=trackstar','myusername','mypassword');
$connection->setActive(true);
and it's still ok.
Please help. Thanks.

Help













