Can Select Fields Be Specified For Related Model Using Cdbcriteria?

Can we specify the fields to be selected from a related model using CDbcriteria? we can specify the field of primary model using "select’ property, but how can we specify for related model?

e.g we have Models User and Group

User Belongs to Section, Section Has Many User


in User Model

$crietia=new CDbcriteria();

$criteria->with='Section';

$criteria->select=array('name',designation);

Here name & designation are column of User table, if i try to give


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

This does not work





$criteria = new CDbCriteria;

//here for relational Table Section

$criteria->with = array('section'=>array('select'=>'alias.section_name'));

//here for User

$criteria->select = array('t.name','t.designation'),




alias is referred to the alias declared in Relation of your Model User ex:




 public function relations() {


        return array(

         

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

                  

        );

    }



Thanks for the info, what if no alias is given in relations? in my Group model i have :


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(

	    'owner' => array(self::BELONGS_TO, 'User', 'owner_id'),

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

	);

    }