我有2张桌子:“tblcongvanden”(ID,tencongvan)(1)--------<-(n)“tblcanbothuchien”(ID,maCongVan(FK),maCanBo,daXem)
在 congvanden 的模型(tblcongvanden 表)中,我有一个关系:
public function relations() {
return array(
'canbothuchien' => array(self::HAS_MANY,'canbothuchien','maCongVan'),
'mucdomat' => array(self::BELONGS_TO,'mucdomat','maMucDoMat'),
);
}
我有一个功能
public function dsCVDchuaXem(){
$userid = canbo::model()->find('tenDangNhap=:ten',array(':ten'=>Yii::app()->user->id))->ID;
$criteria = new CDbCriteria;
$criteria->with= array('canbothuchien','mucdomat');
$criteria->condition = 'maCanBo=:ma';
$criteria->params= array(':ma'=>$userid);
$criteria->compare('t.ID',$this->ID);
$criteria->compare('tieuDe',$this->tieuDe,true);
$criteria->compare('soDen',$this->soDen,true);
$rev=$this->ngayDen;
$rev = preg_replace('/^(\d{1,2})-(\d{1,2})-(\d{2,4})$/',"$3-$2-$1",$rev); //for day-month-year
$criteria->compare('ngayDen', $rev,true);
$rev=$this->ngayThang;
$rev = preg_replace('/^(\d{1,2})-(\d{1,2})-(\d{2,4})$/',"$3-$2-$1",$rev); //for day-month-year
$criteria->compare('ngayThang', $rev,true);
$criteria->compare('maMucDoMat',$this->maMucDoMat);
$criteria->together = true;
return new CActiveDataProvider($this, array(
'pagination'=> array(
'pageSize'=> 10
),
'criteria'=>$criteria,
));
}
在 index.php 中,如何在 Cgridview 中显示字段“daXem”?
(我输入'value'=>'$data->canbothuchien[0]->daXem'
了错误是“试图获取非对象的属性”,或者如果我输入"value'=>'$data->canbothuchien->daXem"
了它也是错误的)