การหาผลรวมของ Column ใน CGridView
public function getSearchCriteria()
{
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('name',$this->name);
// ... more search conditions
return $criteria;
}
public function search()
{
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$this->getSearchCriteria(),
));
}
public function totals()
{
$criteria=$this->getSearchCriteria();
$criteria->select='SUM(somecolumn)';
return $this->commandBuilder->createFindCommand($this->getTableSchema(),$criteria)->queryScalar();
}