How to replace the placeholder ?? in scopes

Til today, I used scopes with the placeholder ?? to filter the data of my queries. - like this:

public function scopes()

{

return array(


    'rValid'=>array(


        'condition'=>'??.invalid is NULL',


    ),


    'valid'=>array(


        'condition'=>$this->tableName().'.invalid is NULL',


    ),


    'rOrdered'=>array(


        'order'=>'??.contactName',


    ),


    'ordered'=>array(


        'order'=>$this->tableName().'.contactName',


    ),





    );

Now in Yii 1.1, I don’t know how to replace the placeholder to get the result of the query

$posts=Post::model()->valid()->with(‘fullContacts:rValid:rOrderd’)->findAll();

where fullContact is an Alias for the ActiveRecordTable.

Of course I could set "alias" in the scopes function but what if I want to use this table in the same query two times?

How to get the alias for the activeRelation in the scope?

Did you try ‘t.’ as prefix? It’s the new fix alias for the main table in 1.1.

thanks for your fast answer but the problem is another. I’ll try to explain it better.

In the Yii release before 1.1 I could create the following example:

one table ‘contact’ with columns: id, name, parent1 (foreign key), parent2 (foreign key), invalid

ActiveRecordClass for ‘contact’

public function relations()


{


    return array(


            'fullParent1'=>array(self::BELONGS_TO, 'contact', 'parent1','alias'=>'fullParent1'),


            'fullParent2'=>array(self::BELONGS_TO, 'contact', 'parent2','alias'=>'fullParent2')


    );


}





public function scopes()


{


    return array(


            'rValid'=>array('condition'=>'??.invalid is NULL'),                    //for use in relations


            'valid' =>array('condition'=>$this->tableName().'.invalid is NULL'),   //for use in maintable


    );


}

with

Contact::model()->valid()->with(array(‘fullParent1:rValid’,‘fullParent2:rValid’))->findAll();

i could get all valid contacts with valid parents because the ?? became replaced by the alias used in the activeRelation…

Now in Yii 1.1 I don’t know how to solve such problems.

Disambiguating column names