ID:               32980
 Updated by:       [EMAIL PROTECTED]
 Reported By:      tim at xi dot co dot nz
-Status:           Open
+Status:           Closed
 Bug Type:         Documentation problem
 Operating System: Linux
 PHP Version:      Irrelevant
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[2005-05-09 00:10:37] 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.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=32980&edit=1

Reply via email to