#32980 [NEW]: pg_fetch_object example produces warnings
| From: | tim at xi dot co dot nz | Date: | Sun, 08 May 2005 22:10:39 +0000 |
| Subject: | #32980 [NEW]: pg_fetch_object example produces warnings | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969368211@lists.php.net to get a copy of this message | ||
From: tim at xi dot co dot nz
Operating system: Linux
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: pg_fetch_object example produces warnings
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 bug report at http://bugs.php.net/?id=32980&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32980&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32980&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32980&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32980&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32980&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32980&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32980&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32980&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32980&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32980&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=32980&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=32980&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32980&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32980&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32980&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32980&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32980&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32980&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32980&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32980&r=mysqlcfg