January 22, 2014

January 22, 2014
In CakePHP, we can retrive data from database in different ways. In this article, we are going to discuss about How to retrive the data by multiple order priority.

Use the below code to retrive the data from the database using multiple order priority in CakePHP.

$this->paginate = array(
        'conditions' => $conditions,
        'order' => array(
            'Post.name' => 'ASC',
            'Post.created' => 'DESC',
         
        ),
        'paramType' => 'querystring',

);
$this->set('posts', $this->paginate('Post'));

The above code will give the output as Post name Ascending order and Post created as Descending order.

0 comments:

Post a Comment