CAKEPHP – Criando conditions no paginate com outras tabelas

janeiro 11, 2016 em CakePhp, Php por Sândler

 

Montando um Paginate com conditions em todas as tabelas

$this->paginate = array(
‘fields’=>’Financeiro.*,Aluno.*,Usuario.*’,
‘conditions’ => $condition,
‘joins’=>array(
array( ‘table’ => ‘aluno’,
‘alias’ => ‘Aluno’,
‘type’ => ‘LEFT’,
‘conditions’ => array(‘Financeiro.aluno_id = Aluno.id’)
),
array( ‘table’ => ‘usuario’,
‘alias’ => ‘Usuario’,
‘type’ => ‘LEFT’,
‘conditions’ => array(‘Aluno.usuario_id = Usuario.id’)
)
),
// ‘contain’ => array(‘Aluno’ ,’Usuario’),
// ‘link’ => array(‘Financeiro’ => array(‘Aluno’ => ‘Usuario’)),
‘limit’ => 30,
‘order’ => array(‘id’ => ‘DESC’)
);