I am trying to find a way to collect data using sql aggregate functions like max, min and count.
And I found that CStatRelation class seems to be what I want. CStatRelation doc
It can be used in the relation function in Yii’s model class.
The usage is like this:
class SomeModelClass extends CActiveRecord{
public function relations() {
return array(
'bidCount'=>array(self::STAT,'Bid','auction_id'),//it can be used like this
);
}
}
The default value of the rowCount in the example code is the count(*). But what if I want to find the max/min value of a specific column??
How can I modify the code to retrieve the max or the min??
1 Answer