In my database I have 2 tables:
country(id,name)
users(id,countryid)
country ->id= users->countryid;
I’m trying to perform this task with yii relations to get name from country table :
users modals
public function relations()
{
return array(
'linkedIndex' => array(self::BELONGS_TO, 'Country','countryid'),
);
}
public function afterFind()
{
$name = Users::model()->findByPk(1);
}