How to disable defaultScope from other models

I have this multi tenant app. A project has a status and a manager. Status (fk) has no default scope. Model ‘project’ and model ‘person’(manager) have defaultScopes like:

	public function defaultScope()


		return array(





I have a CgridView which displays project name with the manager and the status like:


Declare variables:

class Project extends CActiveRecord



        public $status_list;

        public $manager_list;


	public function rules()



			array('actual_start_date, actual_end_date, status_list, manager_list', 'safe', 'on'=>'search'),



	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(

			'person' => array(self::BELONGS_TO, 'Person', 'person_id'),

			'projectStatus' => array(self::BELONGS_TO, 'ProjectStatus', 'project_status_id'),


[code]	public function search()


		// Warning: Please modify the following code to remove attributes that

		// should not be searched.

		$criteria=new CDbCriteria;

                $criteria->with = array('projectStatus');

                $criteria->with = array('person'); 



                $criteria->compare('',$this->status_list, true);                

in the View - CgridView, i want drop downs lists so that users can pick a value filter:




                        'filter'=>CHtml::listData(Person::model()->findAll(), 'fullname', 'fullname'),






                        'filter'=>CHtml::listData(ProjectStatus::model()->findAll(), 'name', 'name'),



Problem is that i get an SQL statement error. I suspect that it is the 2 default scopes. Here is the error message:


How can i get around this?

Do you see anything wrong with the code?

How do you disable a default scope from another model?

Not really "wrong" but as the SQL error says, ambiguous, because in your case you have more than one column with the same name (tenant_id) in the resulting SQL query.

Disambiguating is possible even in your scopes. See here (there also other posts on the forum):