|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2005-09-14 13:25 UTC] maesa at email dot it
  [2005-09-14 13:47 UTC] sniper@php.net
  [2005-09-14 16:58 UTC] wez@php.net
  [2005-09-14 18:50 UTC] iliaa@php.net
  [2005-09-14 18:54 UTC] maesa at email dot it
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 23:00:01 2025 UTC | 
Description: ------------ A pdo::exec call fails when i try to execute sequential query ( 'OPTIMIZE TABLE' queries ) Reproduce code: --------------- $dsn = 'mysql:dbname=my_database;host=localhost'; $user = 'root'; $password = ''; try { $dbh = new PDO($dsn, $user, $password); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } $dbh->exec( 'OPTIMIZE TABLE my_table' ); print_r($dbh->errorInfo()); $dbh->exec( 'OPTIMIZE TABLE my_table_1' ); print_r($dbh->errorInfo()); Expected result: ---------------- I expected that the second call to $dbh->exec will be successful as the first one, but the second fails. Actual result: -------------- Printing the array returned from $dbh->errorInfo() i obtain for the first call to pdo::exec Array ( [0] => 00000 ) but for the second call Array ( [0] => HY000 [1] => 2014 [2] => 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. )