1

我想在 CakePhp 上限制我的数据库数据。它可以通过 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());  
}
4

1 回答 1

3

你可以试试:

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

有关详细信息,请参阅食谱

于 2010-07-01T10:03:05.503 回答