|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-12-17 04:40 UTC] danack@php.net
[2015-12-17 04:50 UTC] php at ontheroad dot net dot nz
[2020-12-09 16:30 UTC] nikic@php.net
-Status: Open
+Status: Verified
[2020-12-09 16:30 UTC] nikic@php.net
[2020-12-10 09:31 UTC] nikic@php.net
[2020-12-10 09:31 UTC] nikic@php.net
-Status: Verified
+Status: Closed
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 06:00:01 2025 UTC |
Description: ------------ Using an PDO::MYSQL_ATTR_INIT_COMMAND with multiple statements separated by a semicolon triggers "General error: 2014 Cannot execute queries while other unbuffered queries are active.". The example below shows my situation. I want to ensure that UTF8 is handled correctly *and* enforce more strict MySQL behaviour, but it seems I can only set one or the other without triggering this bug. The application I've ran across this is being upgraded from PHP 5.4 using the old mysql library to PHP 5.6 with mysqlnd. Versions * PHP 5.6.14 * phpinfo() mysql Client API version => mysqlnd 5.0.11-dev * Amazon Linux mysql lib - php56-mysqlnd-5.6.14-1.119.amzn1.x86_64 Test script: --------------- <?php $options = array( PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, // This is the default, but here to be explicit PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;SET SESSION sql_mode=traditional', ); $dbo = new PDO( 'mysql:host=myhost.rds.amazonaws.com;port=3306;dbname=mydb;', 'user', 'password', $options ); $dbo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $dbo->prepare('SELECT foo FROM bar'); $stmt->execute(); Expected result: ---------------- Statement prepared and executed. Actual result: -------------- PHP 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.' in /home/foo/minimum.php:18 Stack trace: #0 /home/foo/minimum.php(18): PDOStatement->execute() #1 {main} thrown in /home/foo/minimum.php on line 18