问题描述
我写
mysql_query("SET AUTOCOMMIT=0");mysql_query("开始交易");
在我编写所有查询之前.然后检查是否所有这些都是真的,然后写:
mysql_query("COMMIT");
但是如果其中一个查询失败,我就通过 COMMIT 查询.那么,如果其中一个查询失败,我真的需要 ROLLBACK 函数吗?因为没有 ROLLBACK 它也可以工作.
谢谢.
I write
mysql_query("SET AUTOCOMMIT=0");
mysql_query("START TRANSACTION");
before I write all queries. Then check if all of them are true and then write:
mysql_query("COMMIT");
But if one of query fails, I just pass COMMIT query. So do I really need ROLLBACK function if one of the queries fail? Because without ROLLBACK it also works.
Thanks.
推荐答案
我想您是在问是否有必要执行 ROLLBACK,因为没有它,提交仍然不会得到应用.这在技术上是正确的,但这只是因为交易仍然处于打开状态,因为您还没有结束它.任何隐式提交事务(例如,启动一个新事务)的行为都将像您运行 COMMIT 一样,这与您想要的相反
I think you're asking if executing ROLLBACK is necessary, since without it the commits still don't get applied. That's technically true, but only because the transaction is still open since you haven't ended it. Anything that implicitly commits the transaction (for example, starting a new transaction) will act as though you ran COMMIT, which is the opposite of what you want
这篇关于如果查询失败,是否需要编写 ROLLBACK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)