Set autocommit = 0; Turn off auto-commit
Start transaction; Open a transaction;
---------------------......
Commit formally submit a transaction;
After commit, do you want to restore set autocommit = 1? I see no one else's case is restored, the commit will automatically recover?
Reply to discussion (solution)
Don't need
Because you typically do not perform multiple transaction operations in one program code
Even if it is, it's in your hands.
The connection is broken and the settings are automatically deactivated.
Don't need
Because you typically do not perform multiple transaction operations in one program code
Even if it is, it's in your hands.
The connection is broken and the settings are automatically deactivated.
Still not quite understand:
1.PHP a script that instantiates a DB class once, assuming that the DB object executes 100 commands in the script,
Does he automatically disconnect the connection after executing one command at a time? Or are you always using the same connection? Should not be resumed automatically submitted;
Autocommit default is 1, which commits transactions automatically
You set autocommit =0 to turn off autocommit, apparently this is your personal behavior
So after the end of the transaction, is it necessary to restore autocommit to 1, which is naturally your personal behavior
You just reconnect to the database, autocommit is still 1, regardless of the state of your last operation. This is the server's behavior.
If you were to execute 100 more transactions after a transaction, would you like to shut down or turn on the automatic commit of the transaction?