transactions() public method
Declares which DB operations should be performed within a transaction in different scenarios.
The supported DB operations are: OP_INSERT, OP_UPDATE and OP_DELETE, which correspond to the insert(), update() and delete() methods, respectively. By default, these methods are NOT enclosed in a DB 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,
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 (insert()) should be done in a transaction; and in the "api" scenario, all the operations should be done in a transaction.
public array transactions ( ) | ||
---|---|---|
return | array |
The declarations of transactional operations. The array keys are scenarios names, and the array values are the corresponding transaction operations. |
Please login to continue.