Cakephp按字段列表排序

时间:2013-05-23 07:50:59

标签: php cakephp

如何在cakephp paginate函数

中按字段列表定义顺序

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

其中$ ids包含22,24,29,30,23,25,28,26,27

1 个答案:

答案 0 :(得分:1)

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