#33833 [NEW]: fetch doesn't "finish" unbuffered query when all rows have been fetched
| From: | james at safesearching dot com | Date: | Sat, 23 Jul 2005 01:44:40 +0000 |
| Subject: | #33833 [NEW]: fetch doesn't "finish" unbuffered query when all rows have been fetched | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-82348@lists.php.net to get a copy of this message | ||
From: james at safesearching dot com
Operating system: *
PHP version: 5.1.0b3
PHP Bug Type: PDO related
Bug description: fetch doesn't "finish" unbuffered query when all rows have been
fetched
Description:
------------
When a query is expected to return one row, and therefor
PDOStatement::fetch() is only called once, the query isn't "closed" or
"finished" or whatever you like.
The following calls fetch() twice, and only on the second call does the
statment get released so that another statement can be prepared.
$stmt = $db->prepare('SELECT CURDATE()');
while ($row = $stmt->fetch()) {}
The following calls fetch once, and the statement is not released even
though all the rows have been fetched.
$stmt = $db->prepare('SELECT CURDATE()');
$row = $stmt->fetch();
Calling $stmt->closeCursor() all over the place seems a little kludgy...
and I'm assuming $stmt->fetchAll(PDO_FETCH_BOUND) doesn't work.
Reproduce code:
---------------
$db = new PDO(
'mysql:dbname=test;host=localhost',
'teecor',
'k3y2t33c0r'
);
$stmt = $db->prepare('SELECT CURDATE()');
$stmt->execute();
$row = $stmt->fetch();
print_r($row);
$stmt = $db->prepare('SELECT CURDATE()');
print_r($db->errorInfo());
Expected result:
----------------
Array
(
[0] => Array
(
[CURDATE()] => 2005-07-22
[0] => 2005-07-22
)
)
Array
(
[0] => 00000
)
Actual result:
--------------
Array
(
[CURDATE()] => 2005-07-22
[0] => 2005-07-22
)
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.
)
--
Edit bug report at http://bugs.php.net/?id=33833&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33833&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33833&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33833&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33833&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33833&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33833&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33833&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33833&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33833&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33833&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33833&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33833&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33833&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33833&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33833&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33833&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33833&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33833&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33833&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33833&r=mysqlcfg