I have some questions to ask regarding active record relations. I have two tables; tbl_country(county_id(pk),country_name) and tbl_application(app_id(pk), nationality_id,…).
In my application view I want to replace the nationality_id and display the country_name base on the nationality_id.
How can I approach this using relations. I have tried different ways to fix this issue but I did not successes. One way that I have tried is as follow;
In my Application Model I have written this relation;
tbl_user(id, name…) tbl_post(id, userId…), by using auto generated view ‘index.php’ for model post. only show 2 fields(id, userId), how do I add user name field which from another table to here.
The relations has been writed inside both user and post model.
postControllor {
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Post', array(
'criteria'=>array(
'with'=>array('user'),
),
));
$this->render('index',array('dataProvider'=>$dataProvider));
}
}