php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6455 odbc_fetch_row stays on last row and will not move to other rows
Submitted: 2000-08-31 01:34 UTC Modified: 2000-08-31 08:55 UTC
From: tysonlt at webmedia dot com dot au Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.2 OS: WinNT SP6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tysonlt at webmedia dot com dot au
New email:
PHP Version: OS:

 

 [2000-08-31 01:34 UTC] tysonlt at webmedia dot com dot au
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 :)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-31 08:55 UTC] kara@php.net
Many ODBC drivers only support forward cursors. To be able to scroll through the resultset, a cursor library (comes with MS and unixODBC drivermanager) needs to be used by giving SQL_CUR_USE_ODBC as additional parameter to odbc_connect().

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 03:01:31 2024 UTC