got this situation. Reports habtm users. So Im trying to paginate just the Reports that are linked to the Auth user… I read when you have a habtm relationship you have to bind the model temporarily using ‘hasOne’ like this:
function index(){
$conditions=array('ReportsUser.user_id'=>$this->Auth->User('id'), 'ReportsUser.report_id'=>'Report.id');
$this->beforeFind();
$this->Report->recursive=0;
$this->set('reports',$this->paginate($conditions));
}
function beforeFind()
{
$this->Report->bindModel('hasOne'=>array('ReportsUser'), false);
}
so here is the issue… that doesn’t work…
that give me no results… I already checked the database for user having any Report, and i logged in with one of those user…
any suggestions?
GOT IT!!
i just had to remove ‘ReportsUser.report_id’=>’Report.id’ cuz cake was searching for it for a second time… so i just left
and i add