本帖最后由 php_cdsn2 于 2014-11-17 11:21:50 编辑
$_mysqli->rollback();$_mysql->atuocommit();和
InnoDB如何使用
------解决思路----------------------一个小例子
<br /> $mysqli=new mysqli("localhost","root","123456","test");<br /><br /> if($mysqli->connect_error){<br /> die($mysql->connect_error);<br /> }<br /> //将提交设为 false(一旦提交,无法回滚)<br /> $mysqli->autocommit(false);<br /> //保存点 ,把当前记录保存<br /> $sql1="update account set balance=balance-1 where id=1";<br /> $sql2="update account set balance=balance+1 where id=2";<br /><br /> $b1=$mysqli->query($sql1);<br /> $b2=$mysqli->query($sql2);<br /><br /> if(!$b1<br><font color='#FF8000'>------解决思路----------------------</font><br>!$b2){<br /> //回滚<br /> $mysqli->rollback();<br /> echo "失败--".$mysqli->error;<br /> }else{<br /> //提交<br /> $mysqli->commit();<br /> echo "成功";<br /> }<br /><br /> $mysqli->close();<br />