With PHP and MySQL, should you check for rollback failures? With PHP and MySQL, should you check for rollback failures? php php

With PHP and MySQL, should you check for rollback failures?


if rollback fails (connection failure for example), the changes will be rollbacked after the connection close anyway, so you don't need to handle the error. When you are in transaction, unless you have explicit commit (or you are running in autocommit mode, which means you have commit after each statement), the transaction is being roll back.

If a session that has autocommit disabled ends without explicitly committing the final transaction, MySQL rolls back that transaction.

The only case you would like to handle rollback error is if you are not exiting from your script, but starting a new transaction later, as starting transaction will implicitly commit the current one. Check out Statements That Cause an Implicit Commit


mysqli_rollback can fail if you're not (never were) connected to the database. Depends on your error-handling before-hand.