1
I’ve hit my head a lot so far to try to understand how Cakephp pagination works with Custom Query’s but haven’t had much success. This is the method I currently have, I want to make a pagination on top of it, how to use the Paginator
in that situation?
function search(){
$this->layout = 'mpf';
$fields = array('Convenio.*','tbl_agencias.gerev');
$join = array(
array(
'table' => 'tbl_agencias',
'type' => 'LEFT',
'conditions' => array('Convenio.centralizadora = tbl_agencias.id')
)
);
$conditions = array(
'OR' => array(
'Convenio.nome LIKE' => "%".$this->request->data['Convenio']['search']."%",
'Convenio.centralizadora' => $this->request->data['Convenio']['search'],
'Convenio.id' => $this->request->data['Convenio']['search'],
),
array(
'AND' => array(
'Convenio.situacao != ' => '-1'
)
)
);
$group = array('Convenio.nome');
$this->set('convenios', $this->Convenio->find('all',array('fields'=>$fields,'conditions'=>$conditions,'joins'=>$join,'group'=>$group)));
}