Gaurav Mehra
Gaurav Mehra

Reputation: 471

Cakephp order by filed list

How can i define order by field list in cakephp paginate function

like

$this->paginate = array(
                        'conditions' => array('Page.provider_id' => $this->provider['Provider']['id']),
                        'order'      => array("FIELD(Page.id,$ids)")
                    );

where $ids contains 22,24,29,30,23,25,28,26,27

Upvotes: 0

Views: 93

Answers (1)

Preetam
Preetam

Reputation: 618

$ids = implode(',', $ids);
$this->paginate = array(
                    'conditions' => array('Page.provider_id' => $this->provider['Provider']['id']),
                    'order'      => "FIELD(Page.id,$ids)"
                );

Upvotes: 1

Related Questions