Traversing The Findall() Result Mannually

I have following 3 models




the relation in Group Model

'members' => array(self::MANY_MANY, 'User', 'int_user_group(group_id,user_id)'),

Relation in User model

'section' => array(self::BELONGS_TO, 'Section', 'section_id'),

I tried this

$criteria = new CDbCriteria();

$criteria->with = array('members' => array('select' => 'members.designation,', 'with' => array('section' => array('select' => ''))));

$criteria->select = 'id,name';

$criteria->condition = '';

$criteria->params = array(':groupID' => $this->id);

$selected_members = self::model()->findAll($criteria);

Now $selected_members will be an array of objects? what is the procedure to traverse this array and access each selected field of 3 tables selected in above code, i want to do some manipulation with the selected results manually using foreach.

something like that :


        $tab = array();

        foreach ($selected_members as $Memmbers) {

            $value = $Members->memeber_id.'operation';

            array_push($tab , $value);



This is not working, this way i can only access the fields of primary table, how to access the selected fields of joining tables?

Not checking your code for errors, however is you wish to access for example an attribute from ‘members’, you do it like this:

    foreach($selected_members as $val)


        $designation = $val->members->designation;