我想在我的cgrid视图中显示另一个模型字段,我正在使用yii模型。 我目前的模型是会员,其他模型是结算: 我的代码:
public function getImportantMembers(){
$criteria = new CDbCriteria;
$criteria->select ='t.*,b.billing_id,b.amount,b.billing_date,b.member_id,b.billing_status';
$criteria->join = 'JOIN billing AS b ON b.member_id = t.id ';
if(isset($_GET['condition']) AND $_GET['condition'] > 0){
$condition = $this->getConditionForImportantMembers($_GET['condition']);
$criteria->addCondition($condition);
}
else{
$criteria->addCondition("b.billing_date > DATE_SUB(NOW(),INTERVAL 2 MONTH) AND b.billing_status='c' AND b.amount >= 150 AND t.status='a'");
}
$criteria->group = 't.id';
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=> Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']),
),
));
}
答案 0 :(得分:0)
您应首先清除成员模型中的关系;
'billing' => array(self::BELONGS_TO, 'Billing', 'id'),
在您看来:
$data->billing->amount