views:

26

answers:

1

I want to use Zend_Paginator but Zend_Paginator requires Zend_Db_Select as input parameter.

My SQL query is some how a little complicated making it so difficult to implement with Zend_Db_Select.

Can i use Zend_Paginator with plain SQL query?

A: 

Yes you can, From the ZF docs:

The primary design goals of Zend_Paginator are as follows:

  • Paginate arbitrary data, not just relational databases
  • Loosely couple Zend_Paginator to other Zend Framework components so that users who wish to use it independently of Zend_View, Zend_Db, etc. can do so

This page gives examples of the kind of the different adaptors available to Zend_Paginator.

For example, to create a paginator using an array (which could be a database result set) you can use the Array adapter:

$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($array));
seengee
If i use it with Array Adapter i have to fetch all results from DB which is not a good approach.
rahim asgari
thats true of course, i was simply providing an example of the flexibility.
seengee
so there is not an appropriate adapter for my situation. yah?
rahim asgari
you could use a cache to prevent fetching all results each time as shown here http://framework.zend.com/manual/en/zend.paginator.advanced.html Tbh though i would look at your SQL as Zend_Db is pretty flexible and you should be able to make it work with Zend_Db_Select
seengee
so, i will ask another question to change my query to Zend_Db_Select object. thx. ;)
rahim asgari