Nested Transactions in Laravel 4.2 and MySQL

184 views Asked by At

In reference to this point: https://www.php.net/manual/en/pdo.begintransaction.php#109753

The following code works, but can it be run safely on production?

DB::beginTransaction();
try {
    // update statements
    DB::transaction(function(){
        // update statements
    });
    // update statements
    DB::commit();
} catch (Exception $e) {
    DB::rollback();
}
1

There are 1 answers

0
AudioBubble On

Yes, it helps maintain the atomic state either the data gets stored or rollback.