gpt4 book ai didi

cakephp - 设置分页条件

转载 作者:行者123 更新时间:2023-12-01 07:55:38 25 4
gpt4 key购买 nike

我正在尝试在 CakePHP 上进行自定义分页,问题是我想传递自定义条件,如下所示:

$conditions['People'] = $this->People->find('all',
array(
'order' => array('People.id DESC'),
'limit' => 16,
'order' => 'People.id DESC'
)
);

$people = $this->paginate('People',$conditions);

这基本上是所有涉及分页的代码,但它不起作用,它抛出它没有找到列 People...

我就是想做自定义条件的分页,也就是想事先设置好条件,有没有办法做到?

最佳答案

你看文档了吗?

根据文档,您应该添加如下条件:

public function list_recipes() {
$this->Paginator->settings = array(
'conditions' => array('Recipe.title LIKE' => 'a%'),
'limit' => 10
);
$data = $this->Paginator->paginate('Recipe');
$this->set(compact('data'));
}

所以猜这应该有效:
public function list_people() {
$this->Paginator->settings = array('order' => array('People.id DESC'),'limit' => 16,'order' => 'People.id DESC');
$data = $this->Paginator->paginate('People');
$this->set(compact('data'));
}

关于cakephp - 设置分页条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27945305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com