In my web app, I have to instantiate a class which extends CDbConnection :
$db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect);
class DBLayer extends CDbConnection
{
...
and @ a further point of my code I have to call a model that extends CActiveRecord :
$tags=Tag::model()->findTagWeights($this->maxTags);
class Tag extends CActiveRecord
On the Yii log I can read “Opening DB connection” 2 times so I’m wondering if there is 2 CDbConnection instances used or if it is only a duplicated log phrase.
Yes there are two connections. This is expected since you auto-open one by default when initiating a CDbConnection (see here). The other one gets opened when using the active-record (which will use the "db" application component - another CDbConnection).
If you need a custom (extended) version of CDbConnection, then you should define the correct class in the config: