这里$ qoptions包含从不同表中获取数据的条件,$ tmp基本上是从不同表中获取diff字段值的查询。现在我应该在哪里添加分页..如果我根据用户表结果添加,而不是根据我的数据得到正确的分页结果。
$tmp=$this->User->find('all',
array(
'fields' => array('User.id', 'User.name','user_details.designation','districts.district_name','User.user_type','User.phone','user_details.annual_frequency','areas.area_name') ,
'joins' => array(array('table' => 'user_details',
'alias' => 'user_details',
'type' => 'INNER',
'conditions' => array('User.id = user_details.user_id AND user_details.annual_frequency>0')
),
array('table' => 'areas',
'alias' => 'areas',
'type' => 'INNER',
'conditions' => array('User.area_id = areas.id')
),
array('table' => 'districts',
'alias' => 'districts',
'type' => 'INNER',
'conditions' => array('areas.district_id = districts.id')
)
),
'conditions' => $qOptions,
)
); $this->paginate = ($tmp)
$p = $this->paginate('User');
答案 0 :(得分:1)