Closed vovanmix closed 7 years ago
Hello! Laravel transactions are nestable, so you can simply embed the operations in a database transaction closure :
DB::transaction(function () {
// Multiple write / update operation
});
Or manually start / commit transaction :
DB::beginTransaction();
// Write operations
DB::commit();
Hi! The thing is that I'm not using Laravel, and I use your ORM as a only gateway to the database.
Analogue is based on Illuminate/Database, so these functions are available all along (yet syntax may differ, as the examples aboves are using facades). http://stackoverflow.com/questions/26490671/how-can-i-implement-transactions-with-laravels-illuminate-database-class
Can you by any chance show an example on how to call it from an instance of the orm? Assuming that I have this instance in $db
, what do I call? I don't use facades and it seems weird to include another depencency just to call a transaction.
Simply call $db->beginTransaction()
, should work
Hi! I need to use custom transaction to wrap multiple write/update operations on different non-related tables. How can I do that using this ORM? Thank you!