I tried to make a db transaction when I made multi queries.
and also I tried to catch the exceptions outside the transaction just like
DB::transaction(function() {
try{
//....db queries
}catch(\Exception $e){
Log::info($e);
}
});
when some exceptions thrown here, the transaction seems like not be rolled back, the data has been changed in the database.
If I do DB::rollBack()
in the catch statement manually, all my data will be fine,
it makes me think if I have to do DB::rollBack()
manually?
but I do remember the doc of Laravel said if I am using DB::transaction
to manage my db queries, when the exceptions threw, DB::rollBack()
will be executed automatically?
It has been changed in Laravel 5.3?