| Adam Harvey 2007-09-12, 8:02 am |
| 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/>
|