0

执行 2 次查询后如何分页?

我有:

   $this->Paginator->settings = array(
                'conditions' => array('Record.status =' => 'published',  
                                              'RecordUser.flagged =' => null, 
                              'Record.category_id =' => $likes
                                ),
                'limit' => 5,
                'order' => array('rate' => 'desc')
            );

我也想这样做:

$this->Paginator->settings = array(
                'conditions' => array('Record.status =' => 'published',  
                                              'RecordUser.flagged =' => null, 
                              'Record.category_id !=' => $likes
                                ),
                'limit' => 5,
                'order' => array('rate' => 'desc')
            );

然后合并结果。问题是第一次查询的结果限制为 5,然后继续到第二页。我希望在显示第二个查询的结果之前来自第一个查询的所有结果。

我该怎么做呢?我正在使用 cakephp 2.4.3

4

1 回答 1

0

为什么你不能只做一个查询并使用 order by?

$likes = implode(',', $likes);

$this->YourModel->virtualFields['in_like'] = "IF(Record.category_id IN ($likes), 0, 1)";

$this->Paginator->settings = array(
    'conditions' => array(
        'Record.status =' => 'published',  
        'RecordUser.flagged =' => null, 
     ),
     'limit' => 10,
     'order' => array('in_like' => 'asc', 'rate' => 'desc')
);
于 2014-03-01T09:51:03.203 回答