#30876 [NEW]: odbc_fetch_row($rs,0) does not reset dataset.
From: rphp at ryanjameson dot com
Operating system: windows 2000
PHP version: 5.0.2
PHP Bug Type: ODBC related
Bug description: odbc_fetch_row($rs,0) does not reset dataset.
Description:
------------
Since upgrading to 5.0 I've found that looping through a recordset ($rs)
via odbc_fetch_row and then attempting to reuse the recordset by calling
odbc_fetch_row($rs,0) seems to put me at the first record of the recordset
versus giving me a "reset" recordset. The result is a subsequent
odbc_fetch_row then puts me at the second item in the record set which is
not how it behaved in previous versions.
In previous versions calling odbc_fetch_row($rs,0) followed by
odbc_fetch_row($rs) would leave you on the first row since the
odbc_fetch_row($rs,0) had in effect reset the recordset. This ability is
mentioned in the user contributed notes for this function.
I have a rather large and intracate library partially built around the
ability to "reset" recordsets. I have been unable to find another way to
do this. Since installing PHP 5.0 all results that relied on this are
missing the first row. :-\
Reproduce code:
---------------
create a simple odbc record set ($rs) by selecting from any table then...
odbc_fetch_row($rs); //moves the pointer
//in past this would reset the pointer
odbc_fetch_row($rs,0);
$cnt = 0;
while (fetch($rs))
$cnt++;
echo "$cnt is one less than the actual result count because it started on
the second row!";
Expected result:
----------------
I expect $cnt to equal the number of rows in the result set because
odbc_fetch_row($rs,0) should reset the set, not move the pointer to the
first row.
Actual result:
--------------
$cnt is one less than the result count.
--
Edit bug report at http://bugs.php.net/?id=30876&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30876&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30876&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30876&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30876&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30876&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30876&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30876&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30876&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30876&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30876&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=30876&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=30876&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30876&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30876&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30876&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30876&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30876&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30876&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30876&r=mysqlcfg
Thread (2 messages)
- rphp at ryanjameson dot com