I've hit my head so far to try to understand how CakePHP's pagination works with Custom Query's but I have not had much success. This is the method I currently have, I want to make a paging on top of it, how to use Paginator
in this 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)));
}