php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #53624 NULL also works for $row
Submitted: 2010-12-28 19:34 UTC Modified: 2011-01-04 15:37 UTC
From: jsnell at e-normous dot com Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.4 OS:
Private report: No CVE-ID: None
 [2010-12-28 19:34 UTC] 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. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-04 15:33 UTC] aharvey@php.net
-Status: Open +Status: Assigned -Package: PostgreSQL related +Package: Documentation problem -Assigned To: +Assigned To: aharvey
 [2011-01-04 15:36 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=307084
Log: Fix doc bug #53624 (NULL also works for $row).
 [2011-01-04 15:37 UTC] aharvey@php.net
-Status: Assigned +Status: Closed
 [2011-01-04 15:37 UTC] aharvey@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.


 [2011-05-08 21:59 UTC] cataphract@php.net
Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&revision=310844
Log: - Merged to 5.3 change in trunk in _php_stream_free. This prevents the segfault
  in the testcase for bug #53624. The testcase still has to be fixed though,
  because it only works as intended on Windows.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 19:01:31 2024 UTC