Answers for "laravel db::transaction with model"

PHP
6

laravel db transaction

DB::beginTransaction();

try {
    DB::insert(...);
    DB::insert(...);
    DB::insert(...);

    DB::commit();
    // all good
} catch (\Exception $e) {
    DB::rollback();
    // something went wrong
}
Posted by: Guest on May-19-2020
0

Db transaction laravel

DB::beginTransaction();

try {
    DB::insert(...);    
    DB::commit();
} catch (\Exception $e) {
    DB::rollback();
    throw $e;
} catch (\Throwable $e) {
    DB::rollback();
    throw $e;
}
Posted by: Guest on July-27-2021

Code answers related to "laravel db::transaction with model"

Browse Popular Code Answers by Language