I have a need to paginate some simple results, which I need the count of the entire rowset, and then rows from a particular offset. I don't really want to execute 2 queries, so I was thinking of using the seek() method of my result set to put the pointer to the required offset, however when I loop through the results it starts over at the beginning of the result set:

<?php

$rows = $model->fetchAll($where, $order);

$rows->seek($page * $resultsPerPage);

echo $rows->current()->id  // echoes correct "seek()" offset ID

foreach ($rows as $r) {  // starts over at the beginning of the rowset
   // add to result set
}

?>

Is this the expected behavior or am I missing something totally obvious? This is with version 1.6.1. Should I just do 2 queries (a query to get the required rows, then a count query without qualifier)?

Thanks!
Jason

--
Jason Austin
Senior Solutions Implementation Engineer
NC State University - Office of Information Technology
http://webapps.ncsu.edu
919.513-4372

Reply via email to