Doc #53624 [Opn->Asn]: NULL also works for $row

From: Date: Tue, 04 Jan 2011 14:33:00 +0000
Subject: Doc #53624 [Opn->Asn]: NULL also works for $row
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5746@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53624&edit=1 ID: 53624 Updated by: aharvey@php.net Reported by: jsnell at e-normous dot com Summary: NULL also works for $row -Status: Open +Status: Assigned Type: Documentation Problem -Package: PostgreSQL related +Package: Documentation problem PHP Version: 5.3.4 -Assigned To: +Assigned To: aharvey Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2010-12-28 19:34:49] jsnell at e-normous dot com 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 this bug report at http://bugs.php.net/bug.php?id=53624&edit=1

« previous php.doc.bugs (#5746) next »