Vote count:
0
im trying to call two stored proceedures one after the other using php and PDO.. but when i try to do that it returns an error saying
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]:
General error: 2014 Cannot execute queries while other unbuffered queries are
active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is
only ever going to run against mysql, you may enable query buffering by setting
the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.'
As you'll could see im alreay using the MYSQL_ATTR_USE_BUFFERED_QUERYattribute too, but still i get the error.
$conn = new PDO("mysql:host=$dbConfig->host;dbname=".$dbConfig->name, $dbConfig->username, $dbConfig->password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
$tables = array();
$table_count = $conn->prepare("SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'milepostdb' AND table_name LIKE 'table_%' ");
$table_count->execute();
while ($data = $table_count->fetch(PDO::FETCH_ASSOC)) {
$table = $data["TABLE_NAME"];
//$result = $conn->prepare("SELECT * FROM $table WHERE time > DATE_ADD(NOW(), INTERVAL -1 WEEK)");//this works perfectly
$result = $conn->prepare("CALL sp_project_time_interval('$table')");
$result->execute();// place where the error triggers
$count = $result->rowCount();
if($count>0){
$exc = $conn->prepare("CALL sp_weekly_project_report('$table')");
$exc->execute();
while($finalRes = $exc->fetch(PDO::FETCH_ASSOC))
{
$tables[] = $finalRes;
}
}
}
asked 24 secs ago
Cannot call the mysql stored procedures in PDO
Aucun commentaire:
Enregistrer un commentaire