我正在使用cakephp 1.26并进行分页。 你能帮我解决下面的代码吗? 我无法弄清楚代码中的错误。
$this->set('posts', $this->paginate = array('order'=>array('Post.created'=> 'DESC'), 'conditions'=>array('Post.zero'=>'0'), 'limit'='6'
)
);
在.ctp文件中我有:
<table>
<tr><td>
<?php echo $paginator->numbers(); ?>
<?php
echo $paginator->prev('Previous', null, null);
echo $paginator->next(' Next', null, null);
?>
</td></tr>
</table>
答案 0 :(得分:2)
你的代码很糟糕。您无法在函数调用中进行赋值。要么:
$this->set('posts', $this->paginate('Post',array(
'order' => array('Post.created' => 'DESC'),
'conditions' => array('Post.zero' => '0'),
'limit' => '6'
)));
或:
$this->paginate = array(
'order' => array('Post.created' => 'DESC'),
'conditions' => array('Post.zero' => '0'),
'limit' => '6');
$this->set('posts', $this->paginate('Post'));
);
答案 1 :(得分:0)
你的代码不应该是:
$this->set('posts', $this->paginate = array(
'order' => array('Post.created' => 'DESC'),
'conditions' => array('Post.zero' => '0'),
'limit' => '6')
);
答案 2 :(得分:0)
您可以尝试让流程更加清晰。
$this->paginate['Post'] = array('order'=>array('Post.created'=> 'DESC'), 'conditions'=>array('Post.zero'=>'0'), 'limit'='6'));
$posts = $this->paginate('Post');
$this->set(compact('posts'));