Search code examples
zend-frameworkzend-paginator

Zend Paginator with query from string


I have complicated query to my database, which I run via raw SQL query. Not using zend orm. I'd like to add Zend Paginator for my query.

From Zend docs, I've found, that I need to give all records to Zend Paginator adapter, and he make COUNT() and LIMIT by his own.

I have situation like this:

$sql = 'complicated query'; //LIMIT added "by hand", I'd like to make it automatically via zend_paginator
$q = $db->fetchAll($sql, array(/*paramteres here*/));

Now my question is: how should I use Zend Paginator to make pagination? Which adapter should I use in my situation? It's not possible to manually fetching all rows and use array adapters (about 50000 records in table)

Any help will be appreciated:)


Solution

  • You can use Zend_Paginator_Adapter_Array but it's not the best way. Better way is to rewrite your query to Zend_Db_Select and use Zend_Paginator_Adapter_DbSelect