S
S
Sergey2015-05-16 15:24:44
Yii
Sergey, 2015-05-16 15:24:44

How to combine AR with DAO in Yii2?

How to combine AR with DAO in Yii2?
Using ActiveRecord, I want to apply transactions that can only be done with DAO.
I learned what can be done, I don’t know how to do it.
Tell me how to register in the config and in the controller, so as not to hook AR.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
LAV45, 2015-05-17
@alekskondr

I think this should help
https://github.com/yiisoft/yii2/blob/master/docs/g...

$db = Post::getDb();
$db->transaction(function($db) {
    $db->createCommand($sql1)->execute();
    $db->createCommand($sql2)->execute();
    // ... executing other SQL statements ...
});

E
Evgeny Tupikov, 2015-05-17
@Unclead

If you want to use transactions when saving the model, then you need to override the transaction method in the model class

M
Maxim Timofeev, 2015-05-16
@webinar

So you would have asked the one who said that you can.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question