Doc #53624 [NEW]: NULL also works for $row
| From: | jsnell at e-normous dot com | Date: | Tue, 28 Dec 2010 18:34:50 +0000 |
| Subject: | Doc #53624 [NEW]: NULL also works for $row | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-5721@lists.php.net to get a copy of this message | ||
From:
Operating system:
PHP version: 5.3.4
Package: PostgreSQL related
Bug Type: Documentation Problem
Bug description:NULL also works for $row
Description:
------------
---
From manual page: http://www.php.net/function.pg-fetch-assoc#Parameters
---
The documentation should be updated to reflect that supplying null for $row
will return the next result.
IMO, the copy text for $row in the documentation should read:
"Row number in result to fetch. Rows are numbered from 0 upwards. If
omitted or null, next row is fetched. "
Without this in the documentation, one may expect that supply null would do
any one of the following things:
a) be treated as integer 0, as (int) null === 0, and always return the
first row
b) result in an error/warning for supplying a value which is not accepted
according to the documentation
c) the actual behavior, of fetching the next row
Test script:
---------------
$conn = pg_connect(...);
$result = pg_query('select 1');
$row1 = pg_fetch_assoc($result, null);
$row2 = pg_fetch_assoc($result, null);
Expected result:
----------------
null would be cast to an integer of 0 (since (int) null === 0), resulting
in $row1 and $row2 both containing the same row.
OR documentation would state that null will give you the next result.
Actual result:
--------------
Fetching $row2 will fail, as there is only 1 result.
--
Edit bug report at http://bugs.php.net/bug.php?id=53624&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53624&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53624&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53624&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53624&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53624&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53624&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53624&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53624&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53624&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53624&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53624&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53624&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53624&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53624&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53624&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53624&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53624&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53624&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53624&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53624&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53624&r=mysqlcfg