Retrieve Data By Multiple Order Priority In CakePHP


How you cab retrieve data from database by multiple field order priority………?

In cakePHP you can do easily as shown in below example.

In the following pagination query will output as Model first_name in Ascending order and Model last_name in Descending order.

 
$this->paginate = array(
        'conditions' => array(
                        ‘Model.created_date <‘  =>  ‘2014-01-01’
        ),
        'order' => array(
            'Model.first_name'  => 'ASC',
            'Model.last_name'  => 'DESC',
        ),
);
 
$this->set('data'$this->paginate('Model'));
 
 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s