Sep 30, 2021
0
Level 1
DB::rollBack(); not working on innodb on local pc
The tables affected are InnoDB, but still the Rollback sentence dont works. I try to create a record in a master tabla and then erase all and recreate the records in a subtable of master. The master is created, but when is creating the slave records exception occurs , that's ok, but the rollback is not working, the master record keeps still in the table:
DB::beginTransaction();
try{
$master = new Master();
$master->data = "some data";
$master->user()->associate(\Auth::user());
$master->save();
foreach($slave_data as $sd){
$slave = new Slave();
$slave->Master()->associate($master);
$slave->data = $sd->some_other_data;
// exception occurs here! ^
$slave->user()->associate(\Auth::user());
$slave->save();
}
DB::commit();
} catch(\Throwable $e) {
DB::rollBack();
what I'm missing? The InnoDB is there, all the relations are created and working, all the tables says are InnoDB. But somehow the Rollback is not working...
Please or to participate in this conversation.