Hi guys,
database operations first will be done after having set commit() method. This shows up, that transaction will do propper generally at my system. If I want to set back all operations in case of error, rollback is ineffective, operations won’t be set back. What’s wrong with this code?
function actionDelete($id) {
try {
$transaction = \Yii::$app->db->beginTransaction(); // etc..etc..
$transaction->commit(); ...// etc..etc..
} catch (\Exception $e) {
$transaction->rollBack();// this is ineffective. Deletion won't be undone.Why?
error_handling::error_without_id($e, MailController::RenderBackInCaseOfError);
}
}
Are there any statements in your transaction that are on the list in my link? If so it means that MySQL immediately commits after executing them so transaction is not working like you want.
Coding $transaction = \Yii::$app->db->beginTransaction();
before try block fixed issue. Greeting towards acidka, which helped me, fixing issue. This thread can be closed beeing solved succesfully.