$_mysqli->rollback();
$_mysql->atuocommit();
和InnoDB如何使用
------解决思路----------------------
一个小例子
$mysqli=new mysqli("localhost","root","123456","test");
if($mysqli->connect_error){
die($mysql->connect_error);
}
//将提交设为 false(一旦提交,无法回滚)
$mysqli->autocommit(false);
//保存点 ,把当前记录保存
$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){
//回滚
$mysqli->rollback();
echo "失败--".$mysqli->error;
}else{
//提交
$mysqli->commit();
echo "成功";
}
$mysqli->close();