Transaction Handling With Updates Via Active Record Update And Dao Taking Place Together

I know that when we adopt Active Record updates during a transaction, we should use

$trans = $model->dbConnection->beginTransaction();

And when we adopt DAO updates during a transaction, we should use

$trans = Yii::app()->db->beginTransaction();

But how to begin a transaction when we do update via ActiveRecord and DAO within a transaction?

So far, I have been using

$trans = Yii::app()->db->beginTransaction();

for the mixed up case.

Can anyone guide me here?

if only ActiveRecord class is not customized to return another db connection - your solution is pretty good. Standard implementation of CActiveRecord::getDbConnection returns Yii::app()->db component so you can create transaction as you like.

Thanks you very much, redguy, for your answer. I am using only a single connection.