1
$this->Post->Comment->find
('all', array('conditions' => array('Comment.post_id' => $id)));
I do this query, how to know if returned 5, 7, 10... comments before displaying them in the view?
1
$this->Post->Comment->find
('all', array('conditions' => array('Comment.post_id' => $id)));
I do this query, how to know if returned 5, 7, 10... comments before displaying them in the view?
3
I suppose you’re holding the result in a variable, right? Something like that:
$comentarios = $this->Post->Comment->find('all', array('conditions' => array('Comment.post_id' => $id)));
In this case, use the function count
php to get the amount:
$quantidade = count($comentarios);
1
Use the find('count');
$count = $this->Post->Comment->find
('count', array('conditions' => array('Comment.post_id' => $id)));
Thanks! But in the precise case of the query data also!
@Iwannaknow soh to leave archived, Voce can use both 'Count' and 'all''
At the same time? find('Count', 'all'... ?
@Iwannaknow one at a time hehe
So I do the query and take advantage of it using 'Count' as @bfaveretto put it. But thanks again.
Browser other questions tagged query cakephp-2
You are not signed in. Login or sign up in order to post.
That’s right. Thanks man!
– I Wanna Know