You'd probably want to take a look at CounterCache in the book; this would require a modification (an additional field) to your maincategories table, and a little bit of code, but would ultimately be quicker than a separate query. Another suggestion would be to look at find('count') if you don't want to modify your tables, and to learn how caching works (and use it).
On Jul 3, 11:25 am, Luke <eik...@hotmail.com> wrote: > Hi, > > I have the following issue where I am a bit stuck. I have 3 tables > > maincategories > - id > - maincategory > > subcategories > - id > - subcategory > - maincategory_id > > recipes_subcategories > - id > - recipe_id > - subcategory_id > > The Maincategories are shown as a Navigation. I created an element for > this. Everything works fine. The next step I would like to achieve is > to count the amount of recipes for each maincategory. > > Right now I use this code in my maincategories_controller: > > if(isset($this->params['requested'])) { > return $this->Maincategory->find('all', array('order'=>array > ('Maincategory'=>'asc'), 'recursive' => 0)); > > } > > How do I get the amount of recipes shown with my above Database > struktur? Could someone give me a hint? I am pretty stuck with it and > can't think of a solution. Thank you very much in advance. > > Regards Luke --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---