|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-06-01 15:31 UTC] cmb@php.net
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: cmb
[2020-06-01 15:31 UTC] cmb@php.net
[2020-06-01 15:44 UTC] thebluewalrus at gmail dot com
-Status: Feedback
+Status: Assigned
[2020-06-01 15:44 UTC] thebluewalrus at gmail dot com
[2020-06-01 16:14 UTC] cmb@php.net
-Summary: 2 Connections with different buffer stats
cant run
+Summary: PDO::ATTR_PERSISTENT also accepts a string
key
-Status: Assigned
+Status: Verified
-Type: Bug
+Type: Documentation Problem
-Assigned To: cmb
+Assigned To:
[2020-06-01 16:14 UTC] cmb@php.net
[2020-06-01 16:14 UTC] cmb@php.net
-Package: PDO MySQL
+Package: PDO Core
[2020-06-02 08:42 UTC] phpdocbot@php.net
[2020-06-02 08:42 UTC] phpdocbot@php.net
-Status: Verified
+Status: Closed
[2020-06-02 14:35 UTC] phpdocbot@php.net
[2020-06-02 14:40 UTC] phpdocbot@php.net
[2020-12-30 11:59 UTC] nikic@php.net
[2020-12-30 11:59 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 21:00:01 2025 UTC |
Description: ------------ If 2 PDO connections are opened they seem to be merged. If the first is using unbuffered and second using buffered the first results in a buffered return. If both connections are using unbuffered and the first connection is running the second connection returns: 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. on the first call. Issue produces on machines running 7.3.17 (OS Amazon Linux release 2 (Karoo)) and 7.1.33 (OS Red Hat Enterprise Linux Server release 7.3 (Maipo)). Test script: --------------- Case 1: $db = new PDO("mysql:host=".$dbhost.";dbname=".$dbname, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false)); $db_ub = new PDO("mysql:host=".$dbhost.";dbname=".$dbname, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true)); $stmt = $db->prepare('A QUERY THAT WILL EXCEED MEMORY LIMIT IF ALL ROWS RETURNED'); $stmt->execute(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { //should run out of memory } Case 2: $db = new PDO("mysql:host=".$dbhost.";dbname=".$dbname, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false)); $db_ub = new PDO("mysql:host=".$dbhost.";dbname=".$dbname, $dbuser, $dbpass, array(PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false)); $stmt = $db->prepare('A QUERY THAT WILL EXCEED MEMORY LIMIT IF ALL ROWS RETURNED'); $stmt->execute(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $stmt = $db_ub->prepare('select now()'); $stmt->execute(); } Expected result: ---------------- $stmt should only have 1 row at a time and memory usage should be low Actual result: -------------- Usually results in PHP Fatal error: Allowed memory size ... ini_set('memory_limit', can be used to get the script to run.