问题
The Mysqli documentation indicates that if the call autocommit(false)
returns true, it was successful in disabling the automatic committing of queries.
Still, if I try to rollback the transaction, created like the following code, the information remains deleted.
$dbConn= new mysqli($host, $user, $pass, $db) or die('Could not connect');
$dbConn->autcocommit(false); //returns true
$dbConn->query($deleteQuery);
$dbConn->query($deleteQuery2);
$dbConn->rollback();
What could go wrong in this situation?
回答1:
Rollback only works with InnoDB tables not MyISAM. Make sure the tables you are using in $deleteQuery (query) is InnoDB.
来源:https://stackoverflow.com/questions/19219368/mysqli-rollback-not-working