Mysqli回滚不起作用 [英] Mysqli rollback not working

查看:83
本文介绍了Mysqli回滚不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Mysqli文档指示,如果调用autocommit(false)返回true,则表示已成功禁用查询的自动提交.
不过,如果我尝试回滚像以下代码那样创建的事务,则该信息仍被删除.

The Mysqli documentation indicates that if the call autocommit(false) returns true, it was successful in disabling the automatic committing of queries.
Still, if I try to rollback the transaction, created like the following code, the information remains deleted.

$dbConn= new mysqli($host, $user, $pass, $db) or die('Could not connect');
$dbConn->autcocommit(false); //returns true
$dbConn->query($deleteQuery);
$dbConn->query($deleteQuery2);
$dbConn->rollback();

在这种情况下会出什么问题?

What could go wrong in this situation?

推荐答案

回滚仅适用于InnoDB表,不适用于MyISAM.确保在$ deleteQuery(查询)中使用的表是InnoDB.

Rollback only works with InnoDB tables not MyISAM. Make sure the tables you are using in $deleteQuery (query) is InnoDB.

这篇关于Mysqli回滚不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆