php - Zend_Paginator adapter for SolrQuery -


I am currently working in a Zend_Paginator adapter for PECL SolrQuery. I have no way to avoid duplicate queries. Does anyone have a better implementation?

  & lt ;? Php require_once 'Zend / Paginator / Adapter / Interface.php'; Class Xxx_Paginator_Adapter_SolrQuery implements Zend_Paginator_Adapter_interface {Private $ query; Private $ customer; Public function __ composition (SolrQuery $ query, $ client) {$ this- & gt; Query = $ query; $ This- & gt; Client = $ client example SolrClient? $ Customer: new solrclient ($ customer); } Public Function Number () {$ this- & gt; Query-> Setroe (0); Return $ $-> Execute () - & gt; NumFound; } Public function getItems ($ offset, $ itemCountPerPage) {$ this- & gt; Query-> Set start (offset offset) - & gt; Setup ($ itemCountPerPage); Return $ - this- & gt; Execute () - & gt; Docs; } Execute a personal function () {$ response = $ this- & gt; Client- & gt; Query ($ -----; Query) - & gt; GetResponse (); Returns $ reaction ['response']; }}    

You want to do this based on SolrObject for feedback, rather than query All your necessary information is there.

  $ solrResponse = $ solrClient- & gt; Query ($ query); $ SolrObject = $ solrResponse- & gt; GetResponse (); $ Paginator = New Zend_Paginator (new Xxx_Paginator_Adapter_SolrQuery ($ solrObject));    

Comments