如何在Cakephp3中为paginate添加条件..
这是我的代码:
$this->paginate = [
'contain' => ['Users']
];
$proprietes = $this->paginate($this->Proprietes);
$this->set(compact('proprietes'));
$this->set('_serialize', ['proprietes']);
例如这样的东西:
$this->paginate($this->Proprietes)->where(['status'=>'pending']);
感谢您的帮助。
答案 0 :(得分:6)
Reading the documentation helps.阅读整个页面。它甚至包含示例代码:
angular.module('myApp')
.controller('MainCtrl', function ($scope,serviceAjax) {
...
});
答案 1 :(得分:6)
来自官方网站上的Bookmarker tutorial。
public function index()
{
$this->paginate = [
'conditions' => [
'Bookmarks.user_id' => $this->Auth->user('id')
/* for a LIKE clause equivalent use :
'Bookmarks.title LIKE ' => '%abc%' */
]
];
$this->set('bookmarks', $this->paginate($this->Bookmarks));
$this->set('_serialize', ['bookmarks']);
}
文档没有对分页中的条件说太多。这是link of the official documentation。
答案 2 :(得分:0)
public function viewProductList()
{
$shopProduct = $this->ShopProducts->find()->where(['deleted' => 0])->order(['products_id' => 'DESC']);
$this->paginate = array(
'limit' => 5,
);
$this->set('shopProduct', $this->paginate($shopProduct));
}