title: Where will you implement pagination in SOA application in PHP with Zend Framework and Doctrine 2?
body: <p>I've a application which Services to retrieve object from Doctrine 2 repositories.</p>
  
  <p>I'm used to Zend_Paginator, and, well I know that there is adapter for it.</p>
  
  <p>However, I'm wondering where and how should I implement system.</p>
  
  <p>let's say I've such methods:</p>
  
  <pre><code>public function getLatestArticles();
  public function getReviewedArticles();
  public function getSubmitedArticles();
  </code></pre>
  
  <p>Then, in use, in my controller, I'll have :</p>
  
  <pre><code>public function listAction()
  { 
      $which = $this-&gt;_getParam('which', 'latest');
      switch($which)
      {
         case 'latest':
          $articles = $service-&gt;getLatestArticles();
      }
  }
  </code></pre>
  
  <p>But let's say now, I'd like to have a pagination.</p>
  
  <p>How would you implement this?</p>
  
  <p>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?</p>
  
  <p>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.</p>
  
  <p>Any feedbacks &amp; help will be much appreciated.</p>