[PHP-DB] problem using odbc_fetch_row to count rows From: Tyson Lloyd Thwaites (tysonlt <email protected>)
Date: 08/31/00

Hi all,

I am having some trouble resetting odbc_fetch_row.
I am using the following code to get the row count:

                        for ($i=0; odbc_fetch_row($this->qry, $i); $i++);
                        $this->rowcount = $i;
                        odbc_fetch_row($this->qry, 1); <<< this should
reset it, shouldn't it?

However, if I use that, any subsequent calls to odbc_result return the last
row (row $i), regardless of what I
pass to odbc_fetch_row.

The program flow goes like this:

while ($db->MoveNext()) {
    for ($j=1; $j <= $db->GetColumnCount(); $j++) {
         echo $db->GetValue($j);
    }
 }

MoveNext basically does $this->row++, and then calls
odbc_fetch_row($this->qry, $this->row).
$db->GetColumnCount() just returns odbc_result($this->qry, <param>).

If there are three rows, what I get is three lots of the last row. If I
remove that row counting bit and
just hardcode the rowcount into the loop, it works fine.

Any clues? Am I missing something dumb, or is PHP not updating the internal
row pointer properly?

Regards,

Tyson Lloyd Thwaites
IT&e Ltd

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>