The transaction is not rolled back after the sub-table is saved. There is still a piece of data in the main table. Please solve it. Thank you!
The transaction is not rolled back after the sub-table is saved. There is still a piece of data in the main table. Please solve it. Thank you!
There is a problem with your code logic, and commit will eventually be called
You should ensure that when $transaction->rollback()
is executed, the following code will jump out of execution
<code>$t = \Yii::$app->db->beginTransaction(); try{ if($orderModel->save()){ ... if(!$re){ throw new Exception('错误信息'); } ... } $t->commit(); }catch(Excetption $e){ $t->rollback(); throw new Exception($e->getMessage()); }</code>
Also check whether the storage engine of your table is InnoDB
Are you sure the code can run?
It feels like if is missing a curly brace