I usually have the pretty simple DB queries in my code and use ActiveRecords for implementing. But now I have a quite complex query and I think I should handle this via DAO. But I don't understand how right to connect to the database with these both methods?
Assume I executed two queries with AR, then I need to execute one with DAO and, again, one more with AR. The overall result is four queries. But how many connections to the database is creating? I'm not sure if there are three connections in this case.
Anyway, do you know the right way for working with AR and DAO together? May be there is no necessity to establish new connection each time where I wanna use DAO:
$connection=new CDbConnection(Yii::app()->db->connectionString, Yii::app()->db->username, Yii::app()->db->password); $connection->active=true;