Some people on the Internet say that the SQL statement execution error or program error does not execute rollback after the transaction is enabled, the next run will automatically commit program errors will not roll back rollback, but some people say that throwing exceptions and other programs if MySQL has not committed transactions, then AUTOCOM... some people on the Internet say that after the transaction is enabled, if the SQL statement execution error or program error does not execute rollback, the next operation will automatically commit
Rollback is not rolled back when a program error occurs.
However, it is also said that if a program such as throwing an exception has a transaction not committed by MySQL, the parameter automatically submitted by AUTOCOMMIT should be 0 at this time.
However, if you use the MySQL driver in other languages, these drivers generally provide the AUTOCOMMIT recovery function. after the request is processed, the transactions that are not processed are automatically rolled back.
Reply content:
Some people on the Internet say that after the transaction is enabled, if the SQL statement execution error or program error does not execute rollback, the next operation will automatically commit
Rollback is not rolled back when a program error occurs.
However, it is also said that if a program such as throwing an exception has a transaction not committed by MySQL, the parameter automatically submitted by AUTOCOMMIT should be 0 at this time.
However, if you use the MySQL driver in other languages, these drivers generally provide the AUTOCOMMIT recovery function. after the request is processed, the transactions that are not processed are automatically rolled back.
I think you are using PDO by default.
The official document says this:
When the script ends or when a connection is about to be closed, if you have an outstanding transaction, PDO will automatically roll it back. this is a safety measure to help avoid inconsistency in the case where the script terminates unexpectedly -- if you didn't explicitly commit the transaction, then it is assumed that something went awry, so the rollback is saved Med for the safety of your data.
When the script ends or when a connection is about to be closed
This means that when the script ends (including normal or abnormal termination ).
PDO will automatically roll it back
PDO will automatically roll back.
The document is already clear.
If you are not using the PDO driver, you can view the relevant driver documentation or clarify what driver is used in the question.
By the way, the previous mysql_connect () function is no longer recommended for use (was deprecated ).