loop through db result

hi all!

having some trouble with the cdetailview and it is taking me too long.

i want in de cdetailview or ,if that is not possible appart from it, the result of an database query.

if i use the query in the database it returns 2 values. but in the view it returns only the first one, so i need to ‘loop’ something somewhere i quess…

in the view :




	$this->widget('zii.widgets.CDetailView', 

		array(

			'data'=>$model,

			'attributes'=>array(

				'hard_naam',

				'hwso.hsci.coit_id', [b]<<<<<< this is the one who should return more then one..[/b]

			),

		)

	); 



it returns the right record but it doesnt return all records, so that tells me i the relations section is ok, isn’t it??

i’ll post it anyway :




	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(

			'hwso' => array(self::BELONGS_TO, 'HardwareSoort', 'hwso_id','with'=>'hsci'),

		);

	}




i just started YII so i’m a newbie,newbie.

sorry if my question is in the ‘STUPID’ category…

i hope someone can point me in the right direction!

thanx for your time and help!

wietse

Consider two models: (not tested)

City (id,name,state_id)

State (id, name)

model/City.php




	public function relations()

	{

		return array(

			'state'=>array(self::BELONGS_TO,'State','state_id'),

		);

	}



model/State.php




	public function relations()

	{

		return array(

			'cities'=>array(self::HAS_MANY, 'City', 'state_id'),

		);

	}



views/city/view.php




echo $model->state.name



view/state/view.php




foreach($model->cities as $city)

{

     echo $city->name;

}