1

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 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.