php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #32980 pg_fetch_object example produces warnings
Submitted: 2005-05-09 00:10 UTC Modified: 2005-05-09 03:46 UTC
From: tim at xi dot co dot nz Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Linux
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: tim at xi dot co dot nz
New email:
PHP Version: OS:

 

 [2005-05-09 00:10 UTC] tim at xi dot co dot nz
Description:
------------
This is the example from  http://nz2.php.net/manual/en/function.pg-fetch-object.php.

This code always produces a warning on the final row - for example, Warning: pg_fetch_object() [function.pg-fetch-object]: Unable to jump to row 21 on PostgreSQL result index 6 in /etc/apache2/htdocs/php/form_ricerca_result.php on line 59

I think it'd be better for the example to not use $row, and be: 

<?php 

$database = "store";

$db_conn = pg_connect("host=localhost port=5432 dbname=$database");
if (!$db_conn) {
  echo "Failed connecting to postgres database $database\n";
  exit;
}

$qu = pg_query($db_conn, "SELECT * FROM books ORDER BY author");

while ($data = pg_fetch_object($qu)) {
  echo $data->author . " (";
  echo $data->year . "): ";
  echo $data->title . "<br />";
}

pg_free_result($qu);
pg_close($db_conn);

?> 






Reproduce code:
---------------
$row = 0; // postgres needs a row counter 

while ($data = pg_fetch_object($qu, $row)) {
  echo $data->author . " (";
  echo $data->year . "): ";
  echo $data->title . "<br />";
  $row++;
}


Expected result:
----------------
Should only output the rows.

Actual result:
--------------
You get a warning at the end of the loop.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-09 03:46 UTC] chriskl@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Nov 19 16:00:01 2025 UTC