vxgeorge
(Georgevx55)
1
hai everyone,
when am trying to join two tables in CActive dataprovider,am getting "coloumn not found error".
I have two models - feecollection and feecollection_details and i defined the relation between the both as
‘fee_collection_detail’ => array(self::HAS_MANY, ‘FeeCollectionDetail’, ‘fee_collection_id’),
'fee_collection' => array(self::BELONGS_TO, 'FeeCollection', 'fee_collection_id'),
code in controller is
$dataProvider=new CActiveDataProvider(‘FeeCollection’,array(
'criteria'=>array('condition'=>"student_id={$student->id}",'with'=>array('fee_collection_detail'),)));
error : Column not found: 1054 Unknown column ‘student_id’ in ‘where clause’,
field student_id actually belongs to ‘fee_collection_detail’
am i missing something?
?
??
yogii
(Azmayogi)
4
anyway, could anyone explain where the $data variable come from as the code $data->member->name explained on the link?
thanks,
br,
Azma
khushal
(Khushal Fadiya)
5
In both table field name "student_id" is same. So, it gives ambiguity error.
You can try this code in your model file in search() function :
$criteria->with = array('fee_collection_detail');
$criteria->compare('t.student_id',$this->student_id);