Is it possible to use Zend Paginator Class for Solr Search Result. If yes, can please explain how?
Following script successf开发者_Go百科ully working with Database Results.
$paginator = Zend_Paginator::factory($select);
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($page);
Thanks
How are you returning your results? Using an array? (Perhaps like this: http://wiki.apache.org/solr/SolPHP#Solr.27s_PHP_response_format)
If so, you can create a paginator instance easily:
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($array))
or
$paginator = Zend_Paginator::factory($array);
Probably stating the obvious here, but the key is to create a paginator adapter implementing Zend_Paginator_Adapter_Interface
.
So, imitating how the paginator adapters for Zend_Db queries work, I assume that you have some kind of Solr query object that you can pass to the adapter on instantiation. Then in the adapter's getItems($offset, $itemsPerPage)
method, you can modify the query object using those limit params, issue the query, and return the results.
精彩评论