How we can do multiple column ordering in Zend Framework?

Answer

class Application_Model_Users extends Zend_Db_Table_Abstract {

    protected $_name = 'users';
    protected $_primary = 'id';
  
    function users() {
        $select = $this->select()
        ->setIntegrityCheck(false)
        ->from(array('u' => 'users'), array('name as t_name'))->order('first_name asc')->order('last_name des');
         return $this->fetchAll($select);
    }
  
}

class Application_Model_Users extends Zend_Db_Table_Abstract {

    protected $_name = 'users';
    protected $_primary = 'id';
  
    function users() {
        $select = $this->select()
        ->setIntegrityCheck(false)
        ->from(array('u' => 'users'), array('name as t_name'))->order('first_name asc')->order('last_name des');
         return $this->fetchAll($select);
    }
  
}


5 Best Related Posts are Following:
1. How to set Cron in Zend Framework
2. Zend Framework Interview Questions and Answers for Experienced - Page 2
3. Zend Framework Interview Questions and Answers for Experienced
4. Zend Framework Interview Questions and Answers
5. Zend Framework - Free Google Analytics API

1 comment :

  1. How to concatenate two columns in query in Zend Framework?
    $select->from(array('u' => 'users'), array('id','city_id','name','username'))
    ->joinLeft(array('c' => 'cities'), "u.city_id=c.id", array('city_name'=>new Zend_Db_Expr("CONCAT(city, ', ', country)")));

    Reply

 

 
 
 

Most Popular Posts in Last 30 Days

 

All zend Framework 2 Questions

Ask your interview questions on zend-framework-2

Write Your comment or Questions if you want the answers on zend-framework-2 from zend-framework-2 Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---