How can we use these three items together? $ _ mysqli-> rollback ();
$ _ Mysql-> atuocommit ();
And how to use InnoDB
Reply to discussion (solution)
Http://php.net/manual/zh/mysqli.autocommit.php usage manual
A small example
$ Mysqli = new mysqli ("localhost", "root", "123456", "test"); if ($ mysqli-> connect_error) {die ($ mysql-> connect_error);} // Set the submission to false (rollback is not allowed once submitted) $ mysqli-> autocommit (false); // Save the vertex, save the current record $ sql1 = "update account set balance = balance-1 where id = 1"; $ sql2 = "update account set balance = balance + 1 where id = 2 "; $ b1 = $ mysqli-> query ($ sql1); $ b2 = $ mysqli-> query ($ sql2); if (! $ B1 |! $ B2) {// roll back $ mysqli-> rollback (); echo "failed --". $ mysqli-> error;} else {// submit $ mysqli-> commit (); echo "successful" ;}$ mysqli-> close ();
Http://php.net/manual/zh/mysqli.autocommit.php usage manual
Reading the manual and using kindness are two actions and logic. seeing that you are not necessarily good, good is a result, not a casual one. thinking of goodness is not necessarily good, but you can view it immediately. Because it is a behavior
A small example
$ Mysqli = new mysqli ("localhost", "root", "123456", "test"); if ($ mysqli-> connect_error) {die ($ mysql-> connect_error);} // Set the submission to false (rollback is not allowed once submitted) $ mysqli-> autocommit (false); // Save the vertex, save the current record $ sql1 = "update account set balance = balance-1 where id = 1"; $ sql2 = "update account set balance = balance + 1 where id = 2 "; $ b1 = $ mysqli-> query ($ sql1); $ b2 = $ mysqli-> query ($ sql2); if (! $ B1 |! $ B2) {// roll back $ mysqli-> rollback (); echo "failed --". $ mysqli-> error;} else {// submit $ mysqli-> commit (); echo "successful" ;}$ mysqli-> close ();
The structure is clear.