quot;Commands out of sync; you can#39;t run this command nowquot; - Caused by mysqli::multi_query(quot;命令不同步;你现在不能运行这个命令- 由 mysqli::multi_query 引起)
问题描述
我正在通过 mysqli::multi_query 运行多个删除操作,但它搞乱了下一个查询.正在抛出以下错误.
I am running multiple deletes through mysqli::multi_query and it is messing up the next query in line. The following error is being thrown.
Error - SQLSTATE HY000.
Sql error: Commands out of sync; you can't run this command now
我是否需要以某种方式清除多查询,以免干扰我的下一个查询?这个错误的原因是什么?
Do I need to somehow clear the multi query so it doesn't mess with my next query? What is the cause of this error?
这就是我运行多查询的方式:
And this is how I am running my multi query:
function deleteSomeTables($args) {
$sql = 'delete 1;delete another;';
if ($database->multi_query($sql)) {
return true;
} else {
return false;
}
}
我在 Windows 7 上使用最新版本的 Xampp
I am using a recent version of Xampp on windows 7
推荐答案
这帮助我消除了命令不同步"错误:
This helped me to remove 'Commands out of sync' error:
do {
$mysqli_conn_obj->use_result();
}while( $mysqli_conn_obj->more_results() && $mysqli_conn_obj->next_result() );
在调用 multi_query 后添加这段代码,它将使用结果集并解决错误.
Add this code just after calling multi_query, it will use the result sets and resolve the error.
这篇关于"命令不同步;你现在不能运行这个命令"- 由 mysqli::multi_query 引起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:"命令不同步;你现在不能运行这个命令
基础教程推荐
- php中的foreach复选框POST 2021-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- 将变量从树枝传递给 js 2022-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- php中的PDF导出 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
