What is causing PDO error Cannot execute queries while other unbuffered queries are active?

前端 未结 4 652
野的像风
野的像风 2021-02-01 09:01

I have the following code:

$dbh = new PDO(\"mysql:host=$host;dbname=$dbname\", $user, $pass);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$dbh->         


        
4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 09:22

    It seems that you have PDO::MYSQL_ATTR_USE_BUFFERED_QUERY set to FALSE.

    And in such a case it is obligatory to make sure that there are no more rows pending for the retrieval. To do so one to run fetch() one extra time, as it seems that fetch() returning false is "releasing" non-buffered resultset somehow. Without such extra call non-buffered resultset remains locked and causing "Commands out of sync" error

提交回复
热议问题