php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44646 next calls of fetchAll method return empty array
Submitted: 2008-04-05 12:38 UTC Modified: 2008-04-05 12:51 UTC
From: getmequick at gmail dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.2.5 OS: win XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: getmequick at gmail dot com
New email:
PHP Version: OS:

 

 [2008-04-05 12:38 UTC] getmequick at gmail dot com
Description:
------------
Fetching rows using different fetch styles works for single PDO::fetch() method, as shown here - http://www.php.net/manual/ru/function.PDOStatement-fetch.php

Hovewer it doesn't work for PDO::fetchAll() method

Reproduce code:
---------------
<?php
$sth = $dbh->prepare("SELECT domain_name, domain_id FROM pub_domains");
$sth->execute();

print_r($sth->fetchAll(PDO::FETCH_ASSOC));
print_r($sth->fetchAll(PDO::FETCH_BOTH));
?>

Expected result:
----------------
<?php
Array
(
    [0] => Array
        (
            [DOMAIN_NAME] => apple.com
            [DOMAIN_ID] => 3
        )

)

Array
(
    [0] => Array
        (
            [DOMAIN_NAME] => apple.com
            [0] => apple.com
            [DOMAIN_ID] => 3
            [1] => 3
        )

)
?>

Actual result:
--------------
<?php
Array
(
    [0] => Array
        (
            [DOMAIN_NAME] => apple.com
            [DOMAIN_ID] => 3
        )

)

Array
(
)
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-05 12:51 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You can only consume a result set *once*.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 08:01:29 2025 UTC