PDO Cannot execute queries while other unbuffered queries are active

You need to free up your connection using the PDOStatement::closeCursor() method

http://www.php.net/manual/en/pdostatement.closecursor.php

I believe

foreach($phones as $phone)
{
    $stmt = db::getInstance()->prepare("CALL phones(:phone)");
    $stmt->bindParam(':phone', $phone, PDO::PARAM_INT, 10);
    $stmt->execute();

    $stmt->closeCursor()

    $result[] = db::getInstance()->query("SELECT @phone;")->fetchAll(PDO::FETCH_ASSOC);
}

should do it for you

Leave a Comment