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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2021 The PHP Group
All rights reserved.
Last updated: Thu Mar 04 07:01:26 2021 UTC