have any one got an idea how to made CDbCriteria working with relations?
I have already write about this problem before month but nothing useful.
So,
When you set Your query:
$criteria = new CDbCriteria;
$criteria->condition = " table2.id > 0 AND t.id > 0 ";
$criteria->with('table2');
Every time I have an error that there is no such column table2relation.id I cant find an answer for few weeks and this problem is a main problem in Yii wich I cant resolve.
I have try a lot of different ways with conditions with relations but nothing. If I write with(‘table2’) everything is ok, but I need to specify my data so I need to write the condition.
I try to set alias but this nothing helps. My query when she runs without condition with table2.id > 0 works perfect and selects values like: table2.id, table2.value1 etc.
But when I try to set this value in condition it throws an error.
Is there a bug of Yii with relations? I’m using 1.1.4 version.
There is very clearly described that Your condition must be described in a relation (where your relation is described) and than as You say, there’s no need to write the condition in your query because it is described in your relation.
Thanks for an answer, very glad for solving this one
Yes, I have try to use t1 alias and even set alias in a relation but it throws the same error because I have found Your answer somwhere in forums and You suggest to do this in the same way as in this topic.
I’ll try this one once again and if i’ll succed I will post about this.