Suppose we have a User model/table and a Item model/table, and that there’s a MANY_MANY relation between them through a “like” table (i.e. a user likes an item).
Is it possible to define a STAT relation in Item to get the count of users who like the item (i.e. the ‘likes’ count)?
If so how would you define the relation in the relations() method?
And then, are STAT relations supposed to be taken into account in relational queries? I am under the impressiona that when you create a CDbCriteria with a with property that includes various relations and a STAT relation, the stat relation is completely ignored. (and yes, I’m setting together=true).
What I’d like to be able to do is to define the abovementioned likes count as a STAT relation for items, which by default would give a total like count, but then be able to do complex queries involving other relations, imposing specifical conditions so that the likes count get narrowed down (e.g. number of users from a given country that like an item).
By the way, is it possible to access child-relations of a STAT relation in a with?