时间:2021-07-01 10:21:17 帮助过:21人阅读
具体事例如下:
<?php $conn=mysqli_connect("localhost","root","root","test"); //开启事务 mysqli_begin_transaction($conn); try{ mysqli_query($conn,"delete from aaa where uid = 99"); //提交操作 mysqli_commit($conn); echo "finished\n"; }catch (Exception $e){ echo "failed\n"; echo $e->getMessage(); //如果出现错误,则撤销开启事务以后的所有操作 mysqli_rollback($conn); } //提交 mysqli_commit($conn); //关闭数据库 mysqli_close($conn); ?>
MySQLi面向过程实践---事务处理
标签:action www. where myisam lan mit 表格 撤销 parameter