简体   繁体   中英

Where will you implement pagination in SOA application in PHP with Zend Framework and Doctrine 2?

I've a application which Services to retrieve object from Doctrine 2 repositories.

I'm used to Zend_Paginator, and, well I know that there is adapter for it.

However, I'm wondering where and how should I implement system.

let's say I've such methods:

public function getLatestArticles();
public function getReviewedArticles();
public function getSubmitedArticles();

Then, in use, in my controller, I'll have:

public function listAction()
{ 
    $which = $this->_getParam('which', 'latest');
    switch($which)
    {
       case 'latest':
        $articles = $service->getLatestArticles();
    }
}

But let's say now, I'd like to have a pagination.

How would you implement this?

Note that for doing pagination I need to do two things, get the COUNT() then, slice the result. I can easily slice result by adding page or range arguments in my service method, but how will I count?

I'm stuck, as I can't find the best way to do, maybe my system is not adapted and I'm looking at the right thing.

Any feedbacks & help will be much appreciated.

I think you're looking for this answer: Doctrine2 large collections

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM