deib97
(Deib97)
September 23, 2013, 6:44am
1
Hello…
please help me…
i have code model Cabang like this…
public function relations() {
return array(
'createBy' => array(self::BELONGS_TO, 'Users', 'create_by'),
'updateBy' => array(self::BELONGS_TO, 'Users', 'update_by'),
'pilihanCabang' => array(self::HAS_ONE, 'Lookup', 'pilihan'),
);
}
and in my view
array(
'name'=>'pilihan',
'filter'=>CHtml::listData(Lookup::model()->findAll(),'id','name'),
'value'=>'$data->pilihanCabang->name',
),
and result show this : The relation "pilihanCabang" in active record class "Cabang" is specified with an invalid foreign key "pilihan". There is no such column in the table "lookup".
I have table “cabang” with ‘pilihan’ field with contain “1,2”
How to show data with relation table??
deib97
(Deib97)
September 23, 2013, 7:10am
3
please see this
i hope it’s some help.
Show this message
Array to string conversion
deib97
(Deib97)
September 23, 2013, 7:45am
5
model :
public function relations() {
return array(
'createBy' => array(self::BELONGS_TO, 'Users', 'create_by'),
'updateBy' => array(self::BELONGS_TO, 'Users', 'update_by'),
'lookup' => array(self::BELONGS_TO, 'Lookup', 'pilihan'),
);
}
and my view :
array(
'name'=>'pilihan',
// 'filter'=>CHtml::listData(Lookup::model()->findAll(),'id','name'),
'value'=>'$data->lookup->name',
),
I dont have relation in field “pilihan” with table lookup. Just look mysql dump…
thanks
Ankit_Modi
(Ankit Modi)
September 23, 2013, 9:37am
6
model :
public function relations() {
return array(
'createBy' => array(self::BELONGS_TO, 'Users', 'create_by'),
'updateBy' => array(self::BELONGS_TO, 'Users', 'update_by'),
'lookup' => array(self::BELONGS_TO, 'Lookup', 'pilihan'),
);
}
and my view :
array(
'name'=>'pilihan',
// 'filter'=>CHtml::listData(Lookup::model()->findAll(),'id','name'),
'value'=>'$data->lookup->name',
),
I dont have relation in field “pilihan” with table lookup. Just look mysql dump…
thanks
Hi just try the
'value'=>'$data->lookup',
Ankit_Modi
(Ankit Modi)
September 24, 2013, 6:01am
7
Hi also you can write the custome query on value filed.
like
'value'=>'Users::Model()->FindByPk($data->user_id)->username',