statistical query

Suppose I have 3 models: Country, State, City

How do i count how many cities does a Country have using the relation STAT ?

‘cityCount’=>array(self::STAT, ? )

I don’t know if his question is too “newbie” (no one answered yet) but I have the same doubt :)

What I am still doing is getting one object and then the other, but this makes two SELECT’s (or more). Couldn’t this be done with only one?

I would appreciate any help. Thanks!

:blink:

here you should find the solution you are looking for :D

http://www.yiiframework.com/doc/guide/1.1/en/database.arr#statistical-query

I’m having the same problem and statistical query doesn’t seem to be working for this case. Does anyone have another solution?