Some people on the internet say that SQL statement execution error or program error after opening a transaction without executing rollback, the next run will automatically commit
Program error does not roll back rollback
However, some people say that throwing exceptions and other programs if MySQL does not have committed transactions, then the autocommit automatically submit the parameters should be 0.
However, if you use the MySQL driver in other languages, these drivers generally have the function of auto-recovery autocommit, which will automatically ROLLBACK the transaction that is not processed after the request processing is completed.
Reply content:
Some people on the internet say that SQL statement execution error or program error after opening a transaction without executing rollback, the next run will automatically commit
Program error does not roll back rollback
However, some people say that throwing exceptions and other programs if MySQL does not have committed transactions, then the autocommit automatically submit the parameters should be 0.
However, if you use the MySQL driver in other languages, these drivers generally have the function of auto-recovery autocommit, which will automatically ROLLBACK the transaction that is not processed after the request processing is completed.
I think you're using PDO here by default.
This is what the official document says:
When the script ends or when a connection was about to being closed, if you had an outstanding transaction, PDO would automati Cally roll it back. This was a safety measure to help avoid inconsistency in the cases where the script terminates unexpectedly--if you didn ' t Explicitly commit the transaction, then it's assumed that something went awry and so the rollback was performed for the Safet Y of your data.
When the script ends or when a connection are about to be closed
This means that when the script ends (including the normal end or the end of the exception).
PDO would automatically roll it back
PDO is automatically rolled back.
The documentation has been made very clear.
If you are not using the PDO driver, you can view the relevant driver documentation, or make clear what drivers are used in the issue.
Incidentally, the previous mysql_connect () function was not recommended for re-use (was deprecated).