The supported DB operations are: [[OP_INSERT]], [[OP_UPDATE]] and [[OP_DELETE]],
which correspond to the
ActiveRecord::insert,
ActiveRecord::update and
ActiveRecord::delete methods, respectively.
By default, these methods are NOT enclosed in a transaction.
In some scenarios, to ensure data consistency, you may want to enclose some or all of them
in transactions. You can do so by overriding this method and returning the operations
that need to be transactional. For example,
php
return [
'admin' => self::OP_INSERT,
'api' => self::OP_INSERT | self::OP_UPDATE | self::OP_DELETE,
the above is equivalent to the following:
'api' => self::OP_ALL,
];
The above declaration specifies that in the "admin" scenario, the insert operation (
ActiveRecord::insert)
should be done in a transaction; and in the "api" scenario, all the operations should be done
in a transaction.