douzhang5199 2014-11-13 16:03
浏览 42
已采纳

有没有办法在MySQL中获取autocommit的默认值?

I'm just wondering as per the title if this can be done? For example, if I was to do something like this:

$this->db->autocommit(false);

But then afterwards I wanted to set it back to it's default value; I can't just assume it's defaults to true and do this:

$this->db->autocommit(true);

I would like to reset it back to it's default value if possible; or what do other people do when wanting a single query to auto commit? Do you always run:

$this->db->autocommit(true);

...before the query to make sure that autocommit is on?

  • 写回答

1条回答 默认 最新

  • dongyou5098 2014-11-13 16:07
    关注

    http://php.net/manual/en/mysqli.autocommit.php

    To determine the current state of autocommit use the SQL command SELECT @@autocommit.
    

    It seems silly to determine if it's on and if not turn it on though.

    Another way would be using:

    SHOW VARIABLES WHERE Variable_name='autocommit';
    

    Also autocommit among other variables are on a per-connection basis, you setting autocommit to true will not affect any other connections. The only way to find what the default value is, is by checking right when the connection is made (before changing the state).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探