Link to home
Start Free TrialLog in
Avatar of R7AF
R7AFFlag for Netherlands

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?
<?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); 
	}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of flob9
flob9
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of R7AF

ASKER

Thank you!