mysqli_multi_query和mysql事务 [英] mysqli_multi_query and mysql transactions
本文介绍了mysqli_multi_query和mysql事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我第一次在mySQL中尝试事务.
I'm experimenting with transactions for the first time in mySQL.
我想知道使用mysqli_multi_query这样做是否安全.也就是说,我可以假设如果任何SQL语句失败,所有内容都会回滚吗?
I am wondering if it is safe to use mysqli_multi_query for this purpose. That is, can I assume that if any of the SQL statements fails, everything will be rolled back?
$query = "
START TRANSACTION;
(a bunch of SQL statements)
COMMIT;
";
if (mysqli_multi_query($connection, $query)) {
do {
if ($result = mysqli_store_result($connection)) mysqli_free_result($result);
} while (mysqli_next_result($connection));
}
谢谢
推荐答案
是的,mysqli_multi_query使用InnoDB处理MySQL事务.
Yes, mysqli_multi_query handles MySQL Transaction using InnoDB's.
这篇关于mysqli_multi_query和mysql事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文