How to define column in search condition

I have code to search across multiple tables, they have columns with the same name, but when I use the following line:


error reported: CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘entityType.typeId’ in ‘where clause’

Anyone knows how to do search with conditions like entityType.typeId=3? or how to make it recognize the typeId of entityType?


Unknown column error ?

Review you configuration at model and take a look at how to use condition in Criteria :)

When you talk about PKs you could take a look at :

You should add an alias in with(). So instead of:

you should use something like:




    'entityType' => array('alias' => 'entityType'),



This is because if you don’t define an alias for the relation Yii will assign one automatically(e.g. “t0”).