我正在通过 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 引起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!