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);

print_r($curdb);

go to CDbConnection class:

http://www.yiiframework.com/doc/api/1.1/CDbConnection

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




print_r(Yii::app()->db->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… :)

:)