My code:
mysql_query("SET AUTOCOMMIT=0");
mysql_query("START TRANSACTION");
insert_query, update_query1, update_query2
mysql_query("COMMIT");
update_query3
Why does update_query3 query doesn’t work if I put it after COMMIT? It works if I put it before the COMMIT. Why is that? It’s really strange.
Thank you
Because
COMMIT(orROLLBACKfor that matter) marks the end of the transaction.You’d have to use:
..to create a new transaction to begin as soon as the current one ends, and the new transaction has the same isolation level as the just-terminated transaction.
But it still means you need to have:
…after the
update_query3to commit the changes.