Get relational query data from multiple models

Hi, I’m wondering how to get the column values from related models when you do a relational query.

For example, suppose I have the following in a controller:

$qdbs_admin = QuoteDb::model()->with(array(


		))->findAll(array('condition'=>'qdb_admins.user_id = ' . Yii::app()->user->id));

and then loop that data into an array:

		$qdbs_admin_list = array();

		$i = 0;

		foreach($qdbs_admin as $qdb_admin)


			$qdbs_admin_list[$i] = $qdb_admin->attributes;



The "attributes" value only gets the column values from the primary table (in this case, the table for QuoteDb).

I have also defined the connections between the models in the relations() function in each model file. How would I go about getting column values of related tables in a single relational query?

$model->attributes only loads the data from the model itself.

If you use with you can have the system auto-fetch the related records.

There’s no difference though when you go to use the relation.

$model->relationName will have already loaded the related records.

I did use with(). So you’re saying $qdbs_admin->qdb_admins->attributes would call the column names of columns from the qdb_admins relation? I tried that out and it didn’t appear to work.