Tuesday 9 December 2014

Multiple column ordering in Zend Framework

Multiple column ordering in Zend Framework

There are different ways to multiple column ordering in Zend. Following are two different ways to do multiple column ordering in Zend Framework. you can use either First way OR Second way.

First Way
->order(array('first_name asc','last_name desc'));

Second Way
->order('first_name asc')->order('last_name desc')


In above code snippet, First It will sort by first_name in ascending order then sort by last_name in descending order. you can also add more than two column in ordering.


Multiple column ordering in MySQL
select * from users order by first_name asc, last_name desc
First It will sort by first_name in ascending order then sort by last_name in descending order.