Re: Iterating through resultset more than once?

From: Date: Wed, 12 Sep 2007 11:11:23 +0000
Subject: Re: Iterating through resultset more than once?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-27907@lists.php.net to get a copy of this message
Quoting john mclaughlin <jackstrummer@yahoo.co.uk>:
wondered if you could help with this: Using DB package I get a resultset from a query and iterate thru it. Only problem is, how do I reset the resultset to point to its first index so I can iterate thru again. The DB.result class doesn't seem to have any relevant methods. Weird. At present I am having to needlessly rerun the query and get a fresh resultset which is incredibly wasteful, obviously.
Manually setting the row number in call to the fetchRow() method should reset the internal counter. For example: $row = $result->fetchRow(DB_FETCHMODE_DEFAULT, 0); That should return the first row, and subsequent calls to fetchRow() should return the second, third, fourth, etc rows. Adam -- Adam Harvey PEAR Profile: <http://pear.php.net/user/aharvey> Blog: <http://xn--9bi.net/>

« previous php.pear.general (#27907) next »