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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
18 - 4 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 05:01:28 2024 UTC