【发布时间】:2019-01-16 20:11:41
【问题描述】:
如何在包含中添加条件以在 Cakephp3 中分页。
这是我的代码:
$this->paginate = [
'contain' => ['Users', 'AssignDrivers.Users', 'Invoices']
];
$bookings = $this->paginate($this->Bookings);
$this->set(compact('bookings'));
$this->set('_serialize', ['bookings']);
例如这样的:
$this->paginate($this->bookings)->where(['Bookings.status'=>'pending', 'AssignDrivers.name LIKE'=>'%John%']);
感谢您的帮助。
【问题讨论】:
-
一种方法是将查询对象传递给分页函数而不是模型。所以,就像
$query = this->Bookings->find()->where(...)->contain(...); $bookings = $this->paginate($query);.
标签: php cakephp-3.0