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 中的输入表单获取日期 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- Laravel 仓库 2022-01-01