https://blog.csdn.net/zhang197093/article/details/52658665
https://www.ivangabriele.com/2013/12/07/php-how-to-execute-a-mysqli-query-after-a-multi_query/
I just got a problem today : I needed to execute a $mysqli->query() after a $mysqli->multi_query() and it didn’t work. Here is the error I got :
Fatal error: Call to a member function fetch_array() on a non-object in […]
为什么多次使用multi_query只有第一次成功,后面的都失败了
这是因为使用multi_query之后必须释放掉它的查询结果,否则之后的查询都会失败,也就是需要不停调用next_result()直到最后一个结果,如果对查询结果并不关心,可以简单的像这样处理。
1 2 3 4 |
while ($mysqli->more_results() && $mysqli->next_result()) { //什么也不做 } |