Table alias is missing in the constructed sql query where clause


I have to find some records in a model with its relations. one of its relations is the same table itself. now when I do the following :

$model = Account::model()->with('profile.comments.account')->find('name=:name', array(':name'=>$name));

The constructed SQL query fail because of the ambiguity of the given condition.

WHERE (name=:name)

I could solve my problem by adding the t before my column name. but I believe that AR should add the alias of the table in the whee clause.

Am I right ?

I found the same flow in Yii-1.1 branch.

In Yii-1.0 you would need to use

in Yii-1.1 this:

If you look in yii demos/blog it also uses t.field instead of tbl_name.field

If you are going to search by some field in ->with() array - this is where you’ll need to apply alias to table name.

Cheers ;)

umm, It doesn’t make any sense to include my table name in my code! what I changed the name of my table in the future, or maybe Yii will replace t with something else!