I am new to Cake PHP but I can give you the sql to get the count
select count(*), maincategory from maincategories mc, subcategories sc, recipes_subcategories rsc where mc.id = sc.maincategory_id AND sc.id = rsc.subcategory_id AND mc.id = $this->params["category_id"] group by mc.id Thanks, Ramu. On Jul 3, 8:25 pm, 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 -~----------~----~----~----~------~----~------~--~---