How to paginate after doing 2 queries?
I have:
$this->Paginator->settings = array(
'conditions' => array('Record.status =' => 'published',
'RecordUser.flagged =' => null,
'Record.category_id =' => $likes
),
'limit' => 5,
'order' => array('rate' => 'desc')
);
and I want to do this as well:
$this->Paginator->settings = array(
'conditions' => array('Record.status =' => 'published',
'RecordUser.flagged =' => null,
'Record.category_id !=' => $likes
),
'limit' => 5,
'order' => array('rate' => 'desc')
);
then merge the results.. The problem is the result on 1st query limits to 5 then continues to the 2nd page. I want all results from the 1st query before the result on the 2nd query displays.
How do I do this? I'm using cakephp 2.4.3
why can't you just make one single query and use the 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')
);