Mysqli回滚不起作用

Mysqli回滚不起作用

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

问题描述

我有一个MySQL数据库,正在使用mysqli.

I have a MySQL db and I am using mysqli.

由于某种原因,我无法使事务正常运行.如果我呼叫$mysqli->rollback(),它不会回滚.

for some reason I can't get transactions to work properly. If I call $mysqli->rollback(), it does not roll back.

示例代码:

$mysqli->autocommit(false);

$sql = "INSERT INTO myTable (name , color) VALUES ('Dan' , 'red')";

$mysqli->query($sql);

$mysqli->rollback();

结果是将另一行添加到myTable.谁能想到一个原因?

Tthe result is that another row is added to myTable. Can anyone think of a reason why?

推荐答案

您正在使用myIsam还是innodb?据我所知,它仅适用于innodb

are you using myIsam or innodb?? becouse it only works for innodb as far as i know

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

08-28 01:39