Yes, I worked through that. My issue is that the ‘visitor_key’ is not a PK or FK and using the STAT relation has not really helped. I thought I would simply access the result columns of the SQL query but not certain how to do that.
Hmm… the easiest way is to add the properties ($pageViewCount, $conversionCount etc) to the model. But it’s quite weird solution I think
Another way that I thought is to add the statistical query (if you can relate those 2 models), and about the ‘visitor_key’ we will put it in the criteria:
in the Visitor model:
public function relations()
{
return array(
'visits' => ... // you may already have this relation
'pageViewCount' => array(self::STAT, 'Visit', 'visitor_id', 'select' => 'SUM(page_view_count)'),
}
If I may add, using STAT relations were the cleanest solution. Adding [font=“Courier New”]pageViewCount[/font] and [font=“Courier New”]conversionCount[/font] properties to the model feels a lot like abuse to me. If you absoluteley have to fetch all data in one query, I’d suggest going through DAO instead.