R7AF
asked on
[Zend / Postgresql] Select query using limit and offset
I'm starting to use Zend Framework and would like to use a query with limit and offset, as the resultset is rather large. If I use the fetchLatest function (see below), I get 10 rows back. I have two questions about this:
1) If I use the fetchSubset function I get an error (Fatal error: Call to undefined method). I suppose I should import a library or something, but don't know how and what.
2) Is there a better method of using limit and offset than the query() function?
1) If I use the fetchSubset function I get an error (Fatal error: Call to undefined method). I suppose I should import a library or something, but don't know how and what.
2) Is there a better method of using limit and offset than the query() function?
<?php
class Countries extends Zend_Db_Table
{
function fetchLatest($count = 10)
{
return $this->fetchAll(null, 'id desc', $count);
}
function fetchSubset($limit = 10, $offset = 0)
{
$sql = 'select * from countries order by id limit '.$limit.' offset ' . $offset;
return $this->query($sql);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER