I am trying to force a join on paginate function of cakephp. A user has messages which means it will be message belongs to user. I have to show them in a list so i need to use paginate here. Problem is it doesnt shows me the record of the model which i intend to bind My code is:
$userId = $this->Session->read('SESSION_ADMIN.id');
$this->helpers['Paginator'] = array('ajax' => 'Ajax');
$this->Message->bindModel(
array(
'belongsTo'=>array(
'Npo'=>array(
'className' => 'Npo',
'foreignKey' => 'reciever_id',
'fields' => 'Npo.username'
)
)
)
);
$this->paginate = array('conditions'=>array('Message.sender_id'=>$userId,'Message.sender'=>'Admin'),
'order' => array('Message.modified DESC'),
'limit' =>'1'
);
$sentMsg = $this->paginate('Message');
//$sentMsg = $this->Message->find('all');
pr($sentMsg);die();
when i uncomment the FIND statement it shows me record but in case of paginate it doesnt. Also it doesnt shows me the join in the paginate query but it does in counting record. Any one have an idea.I dont want to use paginate Join here.Is there a way to enforce a belongs to here?
Regards Himanshu Sharma