The idea of using transactions in MySQL is good. If something goes wrong then the idea of being able to return the transaction is also good.
My question is: In an application, is it worth it to control the transaction, or MySQL should take care of it for me? In other words, there should be an active distrust of Microsoft's convenience, which MySQL gives me?
Example:
try {$ mysqli-> autocommit (0); // Normally, go through the steps of prepping and execution etc, // But I'll use it for a brief if (! $ Mysqli- & gt; query ("..")) throw new exceptions (" .. "); $ Mysqli- & gt; Committed ()} hold (exception $ E) {$ mysqli-> Rollback (); // I'm sure that I get my rollback error (".."); } Instead of giving the autocommit facility, it does its own job
Notes: I'm writing the application set to run a query only at a time There will not be any situation (such as in some (most) banks and other financial applications), where I need to be sure that the two queries that change data are successful.
It mainly wants to control the type of stuff (and there is a definite deficiency in the auto attribute). The number of times the answer is: If you want to ensure that
update (x); Update (y); is an atom, either both updates or no one has been executed, you should close the auto-commit if you are only doing one query, then the transaction is controlled There will be no need to do If your only transaction fails, then there will be nothing to roll back, okay?
On the related note: You may want to read about the transaction.
Comments
Post a Comment