download12749 2014-02-13 10:29
浏览 250
已采纳

COMMIT后无法执行任何MySQL查询

I execute some MySQL queries using START TRANSACTION, but after I execute COMMIT the following queries do not take effect in the database

The following queries were executed using mysqli_query in the same order:

SET names utf8

SET AUTOCOMMIT=0

START TRANSACTION

INSERT INTO table1 (a, b) VALUES (1,2) ;

INSERT INTO table2 (c, d) VALUES (1,1) ;

INSERT INTO table2 (c, d) VALUES (2,1) ;

COMMIT

INSERT INTO table3 (e, f) VALUES (9,7) ; <-- This does not insert anything!!

Note: The last query should be executed out of the START TRANSACTION COMMITblock.

That is really driving me crazy. Because I cannot seem to figure out the problem!!

  • 写回答

2条回答 默认 最新

  • dougong5817 2014-04-07 14:02
    关注

    The problem is because of the SET AUTOCOMMIT=0, so I'll have to query COMMIT after each query.

    So the solution is either to set the SET AUTOCOMMIT=1 or to use COMMIT after each query.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度