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 に制限され、2 ページ目に続くことです。2 番目のクエリの結果が表示される前に、1 番目のクエリのすべての結果が必要です。

どうすればいいですか?私は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 に答える