Hello Yii fellows,
hope, you can help me. I have two Models, "Categories" and "SubCategories", a category has many subcategories, an foreign key (categoryID) exists in SubCategories table. Furthermore I have projects, belonging to exactly one subcategory and thus implicitly one category.
shortly, the relations are:
Category --HAS_MANY–> SubCategory --HAS_MANY–> PROJECT
PROJECT -->HAS_ONE–> SubCategory --HAS_ONE–> Category
Following the guide http://www.yiiframework.com/doc/guide/database.arr in section "Statistical Query" it was an ease to get the count of projects for a certain subcategory.
The problem is that I need the project count for a certain category as well on another place. I could simply achieve this by adding the project counts for every subcategory of the current category, but I was wondering, if it is possible to utilize the STAT skills of Yii, doing this kind of recursive statistical query for me.
Best regards,
Bergtroll