所以,我有 1 个视图,我需要为相同模型的 2 个表进行分页,但条件不同。例如:
Task Model --> 1st pagination --just paginate task assigned to me
--> 2nd pagination --paginate task created by me
有没有办法做到这一点?
public function dashboard() {
$this->layout = 'user';
$limit = 5;
//debug($this->Session->read('Auth.User.id'));
//debug($this->Session->read('Auth.User.group_id'));
//My Task Pagination
$this->paginate = array(
'Project' => array(
'limit' => $limit,
//'contain' => array('ProjectReminderUser.user_id =' . $this->Session->read('Auth.User.id')),
'conditions' => array(
'User.group_id' => $this->Session->read('Auth.User.group_id'),
//'ProjectReminderUser.user_id' => $this->Session->read('Auth.User.id'),
),
)
);
$this->set('myTasks', $this->paginate('Project'));
//debug($this->paginate('Project'));
//Group Task Pagination
$this->paginate = array(
'Project' => array(
'limit' => $limit,
//'contain' => array('ProjectReminderUser.user_id =' . $this->Session->read('Auth.User.id')),
'conditions' => array(
'User.group_id' => $this->Session->read('Auth.User.group_id'),
//'ProjectReminderUser.user_id' => $this->Session->read('Auth.User.id'),
),
)
);
$this->set('groupTasks', $this->paginate('Project'));
//debug($this->paginate('Project'));
}
这段代码还没有区分条件。但我想知道我怎么能做到这一点。因为使用我当前的代码,每次我尝试对页面进行排序或移动时,由于模型相同,它会对两个表执行相同的操作。