Hi,

What is the best practice to work with pagination when there are huge amount
of records, e.g. 100.000 or even more. All examples I found showed how to
use zf2 paginator together with all records or array elements. For example,
let's imagine that there are 100.000 records in the book table and we use
the following method for pagination:

...
public function getBooks($currentPage)
{
        $select = new Select;
        $select->from('book');

        $resultSet = $this->select($select);
        $resultSet->buffer(); 
        $resultSet->next();

        $resultSet->count(); <-- This returns number of ALL records in the table

        $iteratorAdapter = new Iterator($resultSet);
        $paginator = new Paginator($iteratorAdapter);
        $paginator->setItemCountPerPage(10);
        $paginator->setCurrentPageNumber($currentPage);

        return $paginator;
}
...

I'm not sure whether paginator operates with ALL results at once or it
determines itself what to get from a table, i.e. whether all 100.000 records
will be passed to paginator or it will get from a table only 10 records at
once.

So, should I continue using this method or create a logic for limiting
results depending on the current page before the iterator is involved (maybe
to implement some other logic)?

Thanks



--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-How-to-use-paginator-with-huge-number-of-records-tp4659675.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to