Implement Sum Query

I have a code


public function SumDayaTampung(){

   $sumDT = Yii::app()->db->createCommand()

    ->select('sum(daya_tampung) as TotalDT')



   return $sumDT;



$sumDT= DayaTampungS1::model()->SumDayaTampung();



echo $sumDT->daya_tampung;

and I have an error in view:Property "CDbDataReader.daya_tampung" is not defined.

I really need help

using CDbCriteria

        $criteria = new CDbCriteria;

        $criteria->select = '(sum(daya_tampung)) as TotalDT';

        $sumDT =  DayaTampungS1::model()->find($criteria);

        return $sumDT; 

and you can defind public property on DayaTampungS1 model

public $TotalDT;

display the output

echo $sumDT->TotalDT;

i hope it’s works

otherwise you can not use criteria you can follow the my second two step it’s works…on my last commnet

it`s working… thanks