views:

17

answers:

1

Hello,

I want to limit my db data on CakePhp. It can be limited with find command but I don't know is it possible to limit with my usage. Here is my code from posts_controller.php file:

function index() {  
    $this->Post->order = array('order'=>'Post.date DESC','limit'=>5);  
    $this->Post->recursive = 0;  
    $this->set('posts', $this->paginate());  
}
+1  A: 

You can try:

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

For more information see the cookbook.

SpawnCxy
You are great SpawnCxy thank you very much. I am new at CakePhp and/so couldn't understand some basics yet.
Ahmet Kemal