PHP 4.0 Bug #6455: odbc_fetch_row stays on last row and will not move to other rows
| From: | tysonlt at webmedia dot com dot au | Date: | Thu, 31 Aug 2000 05:34:17 +0000 |
| Subject: | PHP 4.0 Bug #6455: odbc_fetch_row stays on last row and will not move to other rows | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-31378@lists.php.net to get a copy of this message | ||
From: tysonlt@webmedia.com.au
Operating system: WinNT SP6
PHP version: 4.0.2
PHP Bug Type: ODBC related
Bug description: odbc_fetch_row stays on last row and will not move to other rows
The problem is that if you loop through a query using odbc_fetch_row, the internal row pointer will
get stuck on whatever the highest row index was.
In the following script, the first three records are printed correctly. In the second loop, the last
record is printed three times.
<?php
//Here we will demonstrate the problem.
$db = odbc_exec(odbc_connect("testodbc","system","manager"),
"select * from Table1");
for ($i=1; $i<=3; $i++) {
odbc_fetch_row($db, $i);
for ($j=1; $j<=3; $j++) {
echo odbc_result($db, $j) . "<BR>";
}
}
//The above works OK. Now, let's try to reset the pointer:
odbc_fetch_row($db, 1); //<<<THIS IS WHERE THE PROBLEM IS>>>//
//And let's go again:
for ($i=1; $i<=3; $i++) {
odbc_fetch_row($db, $i);
for ($j=1; $j<=3; $j++) {
echo odbc_result($db, $j) . "<BR>";
}
}
//The row pointer is stuck on the last record.
?>
I am using PHP-4.0.2 with the appropriate Zend Optimiser. I have made no changes to the supplied
php.ini (optimised) other than adding an include path and enabling the optimiser.
I am using NT4sp6 and Oracle 8i Personal.
Thanks :)