问题
Does mysqli_begin_transaction()
achieve the same functionality as mysqli_autocommit ()
?
回答1:
mysqli_autocommit()
sets autocommit mode permanently. It means that if you set it to 0 and then commit a transaction, the mode will remain 0.mysqli_begin_transaction()
begins a single transaction. It means after commit the mode reverts to its previous state.
besides, it allows you to fine tune a transaction, starting it in one of the following modes:- MYSQLI_TRANS_START_READ_ONLY.
- MYSQLI_TRANS_START_READ_WRITE
- MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT
You can read on the modes in mysql documentation, https://dev.mysql.com/doc/refman/5.7/en/commit.html
来源:https://stackoverflow.com/questions/42628661/what-is-the-difference-between-mysqli-begin-transaction-and-mysqli-autocommit