duannian4784 2018-02-15 17:10
浏览 150

PHP / MySQLi中的“begin_transaction”方法

I'm looking into rollback management with MySQLi, and I'm curious what the value of "begin_transaction" method is. Many examples I look at skip it entirley by turning autocommit off, then executing some queries with success value returned, and testing a compound Boolean based on the return values to commit or rollback the multiple statements.

It doesn't seem like the "begin_transaction" method actually does any useful work in a scenario where we are looking to commit or rollback a group of queries based on the success of all of them. I can see that it adds readability to the code perhaps by explicitely declaring a transaction, but is there a value to "begin_transaction" other than in readability? What real work does it do?

  • 写回答

2条回答 默认 最新

  • dongpo8702 2018-02-15 21:30
    关注

    Only thing that begin_transaction does in contrast with autocommit off is that it does not mess up with autocommit value, so after you commit/rollback transaction stared with begin_transaction the autocommit will be the same as it was before.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入