$_mysqli->rollback ();
$_mysql->atuocommit ();
and InnoDB how to use
Reply to discussion (solution)
http://php.net/manual/zh/mysqli.autocommit.php Use manual
A small example
$mysqli =new mysqli ("localhost", "root", "123456", "test"), if ($mysqli->connect_error) {die ($mysql->connect_ Error);} Set the commit to False (cannot be rolled back once committed) $mysqli->autocommit (FALSE);//save point to save the current record $sql1= "Update account set Balance=balance-1 where id=1 "; $sql 2=" Update account set balance=balance+1 where id=2 "; $b 1= $mysqli->query ($sql 1); $b 2= $mysqli Query ($sql 2); if (! $b 1| |! $b 2) {//Rollback $mysqli->rollback (); echo "Failed--". $mysqli->error;} else{//submit $mysqli->commit (); echo "Success";} $mysqli->close ();
http://php.net/manual/zh/mysqli.autocommit.php Use manual
Reading manuals and making use of them is two acts and logic, see, you are not necessarily good, good is a result rather than a random, want good not necessarily good, but want to see can immediately see. Because seeing is an act
A small example
$mysqli =new mysqli ("localhost", "root", "123456", "test"), if ($mysqli->connect_error) {die ($mysql->connect_ Error);} Set the commit to False (cannot be rolled back once committed) $mysqli->autocommit (FALSE);//save point to save the current record $sql1= "Update account set Balance=balance-1 where id=1 "; $sql 2=" Update account set balance=balance+1 where id=2 "; $b 1= $mysqli->query ($sql 1); $b 2= $mysqli Query ($sql 2); if (! $b 1| |! $b 2) {//Rollback $mysqli->rollback (); echo "Failed--". $mysqli->error;} else{//submit $mysqli->commit (); echo "Success";} $mysqli->close ();
The structure is clear.