$this->Post->Comment->find
('all', array('conditions' => array('Comment.post_id' => $id)));
I make this query, how do I know if it returned 5, 7, 10 ... comments before displaying them in the view?
$this->Post->Comment->find
('all', array('conditions' => array('Comment.post_id' => $id)));
I make this query, how do I know if it returned 5, 7, 10 ... comments before displaying them in the view?
I suppose you're saving the result in a variable, right? Something like this:
$comentarios = $this->Post->Comment->find('all', array('conditions' => array('Comment.post_id' => $id)));
In this case, use the count
function of php to get the quantity:
$quantidade = count($comentarios);
Use find('count');
$count = $this->Post->Comment->find
('count', array('conditions' => array('Comment.post_id' => $id)));