1
我需要在yii Cgridview的頂部顯示最高金額。用總和(金額)排序在yii Cdbcriteria中
我有兩個模型:members
和billing
, member_id是計費模型中的foregion密鑰。 我的模型功能:
public function getImportantMembers(){
$criteria = new CDbCriteria;
$criteria->select ='t.*,b.billing_id,b.amount,b.billing_date,b.member_id,b.billing_status , sum(b.amount) AS totalamount';
$criteria->join = 'JOIN billing AS b ON b.member_id = t.id ';
$criteria->addCondition("b.billing_date > DATE_SUB(NOW(),INTERVAL 2 MONTH) AND b.billing_status='c' AND b.amount > 150 ");
$criteria->group = 't.id';
$criteria->order = " totalamount DESC";
return new CActiveDataProvider(get_class($this),array(
'pagination'=>array(
'pageSize'=> Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']),),
'criteria'=>$criteria,
));
}
但這個函數顯示不正確金額最高的頂部或量降序 我該如何解決這個問題?
謝謝,我正在努力。 – user2703611