I want to count some data from my database and then display the amount
in my view.
>From reading the manual I would think the proper MVC was would be to
make a function in my Model that counts the records in the field and
then use the controller to send the result of that Model function to
my view. However I am a bit confused because in lots of tutorials I
have been reading ppl skip the model and put the count code right into
the controller.

so what is better? doing it like this:

Model:
function count_categorys($category) {
        return $this->find('count', array('conditions' =>
array('Post.category_id' => "=$category")));
}

Controller:
$this->set('test', $this->Post->count_categorys($category));

Or should I do it like this:
Contoller:
$this->set('test', $this->Post->find('count', array('conditions' =>
array('Post.category_id' => "=$category"))));
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to