Model relations question

Can I set relation that can’t join with id




class User extends CActiveRecord

{


        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(

                    'client' => array(self::BELONGS_TO,'Client','profile')

		);

	}


	public function search()

	{

		$criteria=new CDbCriteria(array(

                        'with'=>'client',  

                ));

                $criteria->compare('id',$this->id);


		return new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

                        'pagination' => array('pageSize' => 10),

		));

        }



output: Client.id = User.profile

but I want: Client.name = User.profile

Hi andjelko

You can use the "on" option to specify the join:

http://sudwebdesign.com/relations-using-a-non-primary-key/451

Best regards,

Sune

thanks a lot