0

我的控制器代码:

public $paginate = array(
        'paramType' => 'querystring',
        'limit' => 3,
    );


$this->paginate['Comment'] = array(
                           'conditions' => array('Comment.post_id' => $this->params['id']));

$this->set('comments',$this->paginate('Commant'));

当我做

pr($this->paginate['Comment'] = array(
                               'conditions' => array('Comment.post_id' => $this->params['id']))); exit; 

输出是数组

(
    [conditions] => Array
        (
            [Response.claim_id] => 4
        )

)

但是,它没有找到与帖子相关的评论,而是显示来自 db 的所有帖子

一旦我尝试过

pr($this->paginate['Comment'] = array(
                                   'conditions' => array('Comment.id' => $this->params['id']))); exit;

结果是一样的

Array

    (
        [conditions] => Array
            (
                [Response.id] => 4
            )

    )

谁能告诉我为什么分页不工作

4

2 回答 2

0

您不需要$this->paginate使用模型索引您的数组。

当您使用 Controller 变量$this->paginate时,意味着它不需要使用模型进行索引。

于 2013-08-07T13:51:34.880 回答
0

利用

public $paginate = array(
    'paramType' => 'querystring',
    'limit' => 3,
); 

在控制器中

$this->set('comments',$this->paginate('Response',
                           array('Response.claim_id' => $id)));

在你的功能中

并在控制器中定义 Paginator 组件

于 2013-08-25T20:56:21.373 回答