Yii Framework Forum: Transaction Handling With Updates Via Active Record Update And Dao Taking Place Together - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Transaction Handling With Updates Via Active Record Update And Dao Taking Place Together Rate Topic: -----

#1 User is offline   ammamon 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 15-September 13

Posted 04 August 2014 - 05:53 AM

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?
0

#2 User is offline   redguy 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 800
  • Joined: 02-July 10
  • Location:Central Poland

Posted 04 August 2014 - 08:09 AM

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.
red
0

#3 User is offline   ammamon 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 15-September 13

Posted 04 August 2014 - 08:01 PM

View Postredguy, on 04 August 2014 - 08:09 AM, said:

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users