Normall, when using DB::beginTransaction()
, it is used with DB::rollBack()
Something like this:
DB::beginTrnsaction();
try {
DB::insert(...);
DB::insert(...);
DB::insert(...);
DB::commit();
// all good
} catch (\Exception $e) {
DB::rollback();
// something went wrong
}
However, what if I forget to add the try catch loop?
i.e.
DB::beginTrnsaction();
DB::insert(...);
DB::insert(...);
DB::insert(...);
DB::commit();
Will the database be changed if one of the insert goes wrong? Or it will automatically rollback?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire