Cakephp默认索引操作和分页器
默认情况下,我的EventsController(或任何控制器)中的“index”(索引)操作返回完整的条目集,我只想显示当前登录用户创建的事件(关联定义良好,并且我的events(事件)表具有外键Cakephp默认索引操作和分页器,cakephp,cakephp-2.0,cakephp-2.1,Cakephp,Cakephp 2.0,Cakephp 2.1,默认情况下,我的EventsController(或任何控制器)中的“index”(索引)操作返回完整的条目集,我只想显示当前登录用户创建的事件(关联定义良好,并且我的events(事件)表具有外键user\u id) 以下是从蛋糕烘焙控制台命令生成的默认索引操作: class EventsController extends AppController { public function index() { $this->Event->recursive
user\u id
)
以下是从蛋糕烘焙控制台命令生成的默认索引操作:
class EventsController extends AppController {
public function index() {
$this->Event->recursive = 0;
$this->set('events', $this->paginate());
}
....
}
我可能不理解
$this->paginate()
中的某些内容,因为我已经尝试使用$events=$this->find('all',$options)
检索我需要的条目,但它没有做任何事情。有没有办法指定哪些条目将返回到视图的我的条件?设置分页条件的方法在中。基本上,如果您在变量$userID
中有用户id,并且事件有用户id
列,您可以这样做
$this->set('events', $this->paginate('Event', array('user_id'=>$userID)));
非常感谢,我对paginator感到不舒服,这基本上就是我所要求的,而且很有效,谢谢。