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

前端 未结 4 636
野的像风
野的像风 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条回答
  •  醉梦人生
    2021-02-01 09:20

    Just to complete the list of possible mistakes causing this issue ... because I was loosing my hair on this I want to share my solution/finding with you.

    In my case I've tried to sent several statements to the database with PDO::exec

    e.g.

    self::$objDatabase->exec( "SELECT id from testtable; UPDATE testtable SET name = 'example';" );
    

    Only 1 SQL Statement in 1 PDO::exec is allowed and save.

提交回复
热议问题