“Commands out of sync; you can't run this command now” - Caused by mysqli::multi_query

前端 未结 3 1251
再見小時候
再見小時候 2020-12-19 03:03

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.

Er         


        
3条回答
  •  温柔的废话
    2020-12-19 03:46

    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() );
    

    Add this code just after calling multi_query, it will use the result sets and resolve the error.

提交回复
热议问题