php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #46161 pg_fetch_result not going to next row
Submitted: 2008-09-23 13:13 UTC Modified: 2008-09-23 15:13 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: analogue at glop dot org Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.2.6 OS: Debian GNU/Linux
Private report: No CVE-ID: None
 [2008-09-23 13:13 UTC] analogue at glop dot org
Description:
------------
As stated in the documentation from http://php.net/pg_fetch_result when used with 2 parameters, pg_fetch_result should go to the next row when called back.

Parameter row: "Row number in result to fetch. Rows are numbered from 0 upwards. If omitted, next row is fetched."

But when I try to call it multiple times, I always get the same first row.

Is it a bug or am I misunderstanding the documentation ?

Thanks for looking into it.

Reproduce code:
---------------
$conn = pg_connect($conn_string);
$query = 'SELECT name FROM pg_settings';
$result = pg_query($conn, $query);
echo pg_fetch_result($result, 0)."\n";
echo pg_fetch_result($result, 0)."\n";
echo pg_fetch_result($result, 0)."\n";
pg_close($conn);


Expected result:
----------------
add_missing_from
allow_system_table_mods
archive_command


Actual result:
--------------
add_missing_from
add_missing_from
add_missing_from


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-23 13:14 UTC] analogue at glop dot org
Happens on PHP 5.2.6, forgot to specify it.
 [2008-09-23 14:11 UTC] tularis@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

please use the php.general mailinglist for support, NOT the bugs system.

You're misunderstanding the documentation. You're asking again and again for row 0, if you _do not provide_ the argument, you will get the next. So:
echo pg_fetch_result($result, 0)."\n";
echo pg_fetch_result($result)."\n";
echo pg_fetch_result($result)."\n";
would result in the behaviour as you expected.
 [2008-09-23 15:09 UTC] analogue at glop dot org
Sorry but in the documentation, there is no mention of a way to call pg_fetch_result with only one parameter, so I think this is a real documentation problem.
 [2008-09-23 15:10 UTC] analogue at glop dot org
I mean there aren't any square bracket [] around the second and third parameters.
 [2008-09-23 15:13 UTC] tularis@php.net
I'm sorry, you're right, my example was incorrect.
But PLEASE consult with php.general or any other source to find out how to do what you're trying to do. And if you all figure out it IS a bug, and figure out what the documentation SHOULD say, feel free to tell us.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 23:00:01 2026 UTC