Relation

hi

I have a relationship between two tables where I save in database the attribute code.

In grid view appears the code but i want to know the description of the code. but the description of the code is in another table

how can i do that?

Thank you

Hi, first this is the Spanish forum.

model1

code (PK)

description

model2

model2_id (PK)

code (FK)

With a relation to model1 called FK_relation1.

Then, in your model2 CGridView:




...

'columns'=>array(

                array('header'=>'description_code', // or "label", I'm not sure

                     'value'=>'$data->FK_relation1->description,

...



regards.