Yii mysql inner join

hi all!

just started learning yii so please be gentle…

i think my question should be fairly easy but still haven’t found the sollution:

problem : instead the view showing a foreign key int, i want a ‘user-friendly’ name.

normally i would inner join the second table, but how solve it within yii?

situation :

two tables :

[users]

user_id (PK)

user_name

user_city_id (FK)

[cities]

city_id (PK)

city_name

the protected/views/user/view.php :

<?php $this->widget(‘zii.widgets.CDetailView’, array(

'data'=&gt;&#036;model,


'attributes'=&gt;array(


	'user_id',


	'user_name',


            'user_city_id',    &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; this should be city_name


),

)); ?>

don’t know if this has got anything to do with my problem but just in case :

the protected/models/user.php :

public function relations()


{


	// NOTE: you may need to adjust the relation name and the related


	// class name for the relations automatically generated below.


	return array(


		'cities'=&gt; array(self::MANY_MANY, 'cities', 'city_id'),


	);


}

hope someone can show me the way!!!!!

thanx a lot!

wietse

SOLVED :

Found the/a solution :

i changed the bold part in the view to :

<?php

$this->widget(‘zii.widgets.CDetailView’, array(

'data'=&gt;&#036;model,


'attributes'=&gt;array(


	'netw_naam',


	'netw_startip',


	'netw_eindip',


	'netw_subnet',


	'netw_gw',


	'netw_class',

[b] array(

		'label' =&gt; &#036;model[u]-&gt;nwty-&gt;[/u]getAttributeLabel('nwty_naam'), 


        'value' =&gt; &#036;model[u]-&gt;nwty-&gt;[/u]nwty_naam


    ),


    array( 


        'label' =&gt; &#036;model[u]-&gt;nwlo-&gt;[/u]getAttributeLabel('nwlo_naam'), 


		'value' =&gt; &#036;model[u]-&gt;nwlo-&gt;[/u]nwlo_naam


    ),[/b]


	'netw_comment',


),

));

?>

the underlined part nwlo and nwty is the part that reffered to the class name in the relations() function in the model:

in my case :

public function relations()


{


	// NOTE: you may need to adjust the relation name and the related


	// class name for the relations automatically generated below.


	return array(


		[b]'nwty' [/b]=&gt; array(self::BELONGS_TO, 'ipconetwerkentype', 'nwty_id'),


		[b]'nwlo' [/b]=&gt; array(self::BELONGS_TO, 'ipconetwerkenlocaties', 'nwlo_id'),


	);


}

can you paste your code for $model from your user controller -> actionView