I have this transaction, and all my MySQL tables are using InnoDB engine :
\DB::beginTransaction();
try{
User::create([
'name' => 'test',
'status' => 1
]);
array_push($test_array, ['test']);
\DB::commit();
} catch(\Exception $e){
\DB::rollBack();
}
If I dump()
the exception, it says array_push() expects parameter 1 to be array, null given
, because $test_array
is null, but the transaction didn't rollback, and the user is still created. I don't know what I'm doing wrong.
I get the same result while doing this too :
\DB::transaction(function () {
User::create([
'name' => 'test',
'status' => 1
]);
array_push($test_array, ['test']);
});
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire