Hi all.
There is one co-related topic here (stat relation):
http://www.yiiframew…php/topic,1418
But I need something other. Actually I have the following code:
<?php $criteria = new CDbCriteria(); $criteria->select = array('id', 'name', 'COUNT(p.user_id) as votes', 'AVG(p.rating) as rating'); $criteria->order = Yii::app()->params['tables']['post'] . '.date'; $criteria->limit = self::SHORTLIST_SIZE; $criteria->join = 'LEFT JOIN ' . Yii::app()->params['tables']['post_rating'] . ' p ON p.post_id = id'; $criteria->group = 'id'; $current = Post::model()->with(array( 'post_info' => array('select' => 'preview_image'), ))->findAll($criteria);
What is interesting, that the result query in ActiveFinder is what I need. But there Model object has loses COUNT and AVG attributes. This is sad to me.
Could someone explain me "how to get COUNT and AVG using criteria"? Or I have to use CDBCommand class instead?