title: Order By Condition For ResultSet Zend Framework 2?
body: <p>I have one tabel 'cms'  when i call fetchAll() function which fetch all data fetch data with order by id desc means i want to pass orderby condition with fetchAll() function.</p>
  
  <p>My Cms.php page is:</p>
  
  <pre><code>    &lt;?php
      namespace Front\Model;
      use Zend\Db\TableGateway\AbstractTableGateway;
  
      class Cms extends AbstractTableGateway {
  
          public function __construct($adapter) {
              $this-&gt;table = 'cms';
              $this-&gt;adapter = $adapter;
          } 
          public function fetchAll($id) {
                 return $this-&gt;select();
          }
          public function getCmsContent($id){
              $id  = (int) $id;
              $rowset = $this-&gt;select(array('id'=&gt;$id));
              if (!$row = $rowset-&gt;current()){
                  throw new \Exception ('Row not found');
              }
              return $row;
          }
      }
  </code></pre>
  
  <p>My Controller is :FrontController.php is:
         
  
  <pre><code>use Zend\Mvc\Controller\AbstractActionController;
  use Zend\View\Model\ViewModel;
  use Front\Model\Cms;
  use Front\Model\Setting;
  use Front\Model\Slider;
  class FrontController extends AbstractActionController
  {
      public function indexAction()
      {   
  
          return        array('cms_data'=&gt;$this-&gt;getCms()-&gt;fetchAll('1'));             
      }
  
      public function getCms(){
          return $this-&gt;getServiceLocator()-&gt;get('Front\Model\Cms');
      }
  
  }
  </code></pre>
  
  <p>My Model is:
          
  
  <pre><code>namespace Front;
  
  class Module
  {
      public function getAutoloaderConfig()
      {
          return array('Zend\Loader\StandardAutoloader' =&gt;
              array('namespaces' =&gt;
                  array(__NAMESPACE__ =&gt; __DIR__ . '/src/' . __NAMESPACE__,),
              ),
          );
      }
  
      public function getConfig()
      {
          return include __DIR__ . '/config/module.config.php';
      }
      // Add this method:
      public function getServiceConfig()
      {
          return array(
              'factories' =&gt; array(
  
                  'Front\Model\Cms' =&gt;  function($sm) {
                      $dbAdapter = $sm-&gt;get('Zend\Db\Adapter\Adapter');
                      $table     = new \Front\Model\Cms($dbAdapter);
                      return $table;
                  },
  
              ),
          );
      }
  }
  ?&gt;
  </code></pre>
  
  <p>My View:index.php Page is:</p>
  
  <pre><code> &lt;?php print_R($cms_data); ?&gt;
  </code></pre>