如何在CakePhp中限制db查询数据?

如何在CakePhp中限制db查询数据?,cakephp,cakephp-1.3,Cakephp,Cakephp 1.3,我想在CakePhp上限制我的db数据。它可以用find命令进行限制,但我不知道是否可以用我的用法进行限制。以下是我在posts_controller.php文件中的代码: function index() { $this->Post->order = array('order'=>'Post.date DESC','limit'=>5); $this->Post->recursive = 0; $this->set(

我想在CakePhp上限制我的db数据。它可以用find命令进行限制,但我不知道是否可以用我的用法进行限制。以下是我在posts_controller.php文件中的代码:

function index() {  
    $this->Post->order = array('order'=>'Post.date DESC','limit'=>5);  
    $this->Post->recursive = 0;  
    $this->set('posts', $this->paginate());  
}
您可以尝试:

$this->paginate['Post'] = array('order'=>array('Post.date DESC'),'limit'=>5,'recursive'=>0);      
$this->set('posts', $this->paginate('Post')); 

有关更多信息,请参阅。

您太棒了,非常感谢。我是CakePhp新手,所以还不能理解一些基础知识。