1DB::beginTransaction();
2
3try {
4 DB::insert(...);
5 DB::insert(...);
6 DB::insert(...);
7
8 DB::commit();
9 // all good
10} catch (\Exception $e) {
11 DB::rollback();
12 // something went wrong
13}
1DB::beginTransaction();
2
3try {
4 DB::insert(...);
5 DB::commit();
6} catch (\Throwable $e) {
7 DB::rollback();
8 throw $e;
9}
1DB::beginTransaction();
2try { /** Statement */ DB::commit(); }
3catch (\Exception $e) { /** Statement if failed */ DB::rollback(); }