[SOLVED] Strange problem with AR

I have three AR models.

Model Window (table Windows) has relation:

		return array(

                    'company'  =>  array(self::BELONGS_TO, 'Company', 'companyId','together'=>true),

                    'type'   =>  array(self::BELONGS_TO, 'WindowType', 'typeId','together'=>true)



Also I have model WindowType with table WindowTypes and model Company with table Companies.

Finding Window model record by PK is easy. But I need to find it by company.url and type.url at once.

I’ve tried the following:

$window = Window::model()






That’s returned me an error about unexisting column WindowTypes.url. The only way it works is when I replace WindowTypes with t1 and Companies with t2.

So, the question: Is there any correct way to make such query ? Or is it a bug?

Try ‘??.url’, “??” will be automatically replaced with the correct alias by Yii

Thanks. I’ll try

you should provide an alias for the table name within the condition. Otherwise yii will create it for you like ‘t1’ - ‘tn’. If an alias is given in a sql statement like ‘select * from table as t1’ you must use t1 in the whole statement.

Thanks. I’ve already understood it with the help of Xorshadow