Db Connection Values

I can extract db connection values in username and password

echo Yii::app()->db->username; //username

echo Yii::app()->db->password; //password

But, I don’t know how to get variable for “host” and “dbname”. Please help…

Thank you…

Try this

$curdb  = explode('=', Yii::app()->db->connectionString);


go to CDbConnection class:


and look at what’s available. I would bet on attributes:


no tested though!

Thank you Balu, with your explode solution I can get my dbname value in $curdb[2].

Thank you for bettor too… :)