Suppose I have codes as below
DB::beginTransaction();
try {
...
DB::commit();
} catch (\Exception $e) {
DB::rollback();
return back()->with('err', translate('something_went_wrong', 'Something Went Wrong. Please contact customer support.'));
}
Do I still need to call DB::rollback()
? I saw similar codes on stackoverflow but I am wondering the necessity of having DB::rollback()
because the transaction is never committed if something went wrong in between.