|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-07-13 18:32 UTC] david at grudl dot com
Description:
------------
This code throws "SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active" on line 4.
The solution is to use exec() instead of query(), but I think that it is bug since there is no other active query.
Test script:
---------------
$pdo = new PDO('mysql:host=127.0.0.1', '...', '...');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
$pdo->query('USE nette_test');
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 16:00:01 2025 UTC |
kbenton@localhost ~ php --version PHP 7.2.6 (cli) (built: May 22 2018 16:22:08) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies kbenton@localhost ~ php testme.php Exception caught: 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. Here! kbenton@localhost ~ cat testme.php <?php try { $pdo = new PDO('mysql:host=127.0.0.1', 'aql_app', '@ql_@pp'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); $pdo->query('USE aql_db'); } catch ( Exception $e ) { echo "Exception caught: {$e->getMessage()}\n"; } echo "Here!\n"; kbenton@localhost ~