Operating environment: PHP 5.5.30-x64,mysql 5.6.27
Error code: Cannot execute queries while other unbuffered queries is active. Consider using Pdostatement::fetchall (). Alternatively, if your code is a ever going to run against MySQL, you may enable query buffering by setting the Pdo::my Sql_attr_use_buffered_query attribute.
on-line explanations :
The test was found because several SQL statements were executed in the previous execute (that is, a semicolon-delimited select/insert/update that performed multiple times consecutively). That is, the query is queried again without ending the previous one, so it will go wrong, so release the previous query.
the code on the manual :
<?php if ($db-getattribute (PDO:: attr_driver_name) = = ' mysql ') { $stmt = $db, prepare (' SELECT * from foo ', Array (PDO:: Mysql_attr_use_buffered_query = true);} else {
If This attribute are set to TRUE on a pdostatement, the MySQL driver would use the buffered versions of the MySQL API. If you ' re writing portable code, you should use Pdostatement::fetchall () instead.
Tested many times or had problems .....
The code runs multiple query,optimize table,delete operations. This error was found to be caused by optimize table. The code runs correctly after the comment is dropped.
Use optimize TABLE:
<?phpclass database extends pdo{//table prefix public $prefix = '; Some Code//optimization table function optimize ($table) {$stmt = $this, prepare (' Optimize table '. $this->prefix. $table .‘ ", Array (PDO:: Mysql_attr_use_buffered_query = true); return $stmt-Execute ();}
La La ...
PDO MySQL Error: cannot execute queries while other unbuffered queries is active