doctrine 2 and zend paginator

前端 未结 4 941
闹比i
闹比i 2021-01-01 01:19

i want to use doctrine with zend_paginator

here some example query :

$allArticleObj = $this->_em->getRepository(\'Articles\'); $qb

4条回答
  •  星月不相逢
    2021-01-01 02:12

    The upshot, of course, is that you have to implement the Zend_Paginator_Adapter_Interface, which essentially means implementing the two methods:

    count()

    getItems($offset, $perPage)

    Your adapter would accept the Doctrine query as a constructor argument.

    In principle, the getItems() part is actually straightforward. Simply, add the $offset and $perPage restrictions to the query - as you are doing in your sample - and execute the query.

    In practice, it's the count() business that tends to be tricky. I'd follow the example of Zend_Paginator_Adapter_DbSelect, replacing the Zend_Db operations with their Doctrine analogues.

提交回复
热议问题