#30876 [Opn->Bgs]: odbc_fetch_row($rs,0) does not reset dataset.

From: Date: Tue, 18 Jan 2005 15:39:59 +0000
Subject: #30876 [Opn->Bgs]: odbc_fetch_row($rs,0) does not reset dataset.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-72387@lists.php.net to get a copy of this message
 ID:               30876
 Updated by:       tony2001@php.net
 Reported By:      rphp at ryanjameson dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         ODBC related
 Operating System: windows 2000
 PHP Version:      5.0.2
 New Comment:

The docs say:
"To step through the result more than once, you can call
odbc_fetch_row() with row_number 1, and then continue doing
odbc_fetch_row() without row_number to review the result. If a driver
doesn't support fetching rows by number, the row_number parameter is
ignored."
You should use 1 instead of 0.


Previous Comments:
------------------------------------------------------------------------

[2004-11-24 02:26:43] rphp at ryanjameson dot com

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 this bug report at http://bugs.php.net/?id=30876&edit=1


Thread (2 messages)

« previous php.bugs (#72387) next »