I'm trying to do custom paginates on CakePHP, the thing is that I want to pass custom conditions, something like this:
$conditions['People'] = $this->People->find('all',
array(
'order' => array('People.id DESC'),
'limit' => 16,
'order' => 'People.id DESC'
)
);
$people = $this->paginate('People',$conditions);
That's basically all the code involving pagination, but it doesn't work, it throws that it doesn't find the column People...
I just want to do paginations with custom conditions, that is, I want to set the conditions beforehand, is there a way to do that?
Did you take a look at the documentation?
According the documentation you should add conditions like this:
public function list_recipes() {
$this->Paginator->settings = array(
'conditions' => array('Recipe.title LIKE' => 'a%'),
'limit' => 10
);
$data = $this->Paginator->paginate('Recipe');
$this->set(compact('data'));
}
So guess this should work:
public function list_people() {
$this->Paginator->settings = array('order' => array('People.id DESC'),'limit' => 16,'order' => 'People.id DESC');
$data = $this->Paginator->paginate('People');
$this->set(compact('data'));
}