my countries table has these columns
-
CountryID
-
CountryCode
-
CountryName
the model has this relation
return array(
'worldareascities' => array(self::HAS_MANY, 'Worldareascities', 'CountryID'),
'worldareasstates' => array(self::HAS_MANY, 'Worldareasstates', 'CountryID'),
);
now I have states table and has these columns
-
CountryID
-
RegionID
-
StateID
-
StateCode
-
Statename
where CountryID serves as a constraint and foreign key that references the countries table CountryID column
the states model has these relation
return array(
'worldareascities' => array(self::HAS_MANY, 'Worldareascities', 'StateID'),
'country' => array(self::BELONGS_TO, 'Worldareascountries', 'CountryID'),
);
When I created a CRUD for states, the admin area displayed like this
now my question is, how will I display the country names instead of the country id ?
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'worldareasstates-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'CountryID',
'RegionID',
'StateID',
'StateCode',
'StateName',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
on the other hand I can atleast produce the text value of a certain row by using an array("name","value")
but this time I got stuck
how to convert this?
SELECT CountryName FROM gg_t_worldareascountries AS c, gg_t_worldareasstates AS s
WHERE c.CountryID = s.CountryID;
and place it to the
array(
'name' => 'Country Name',
'value' => ?
),