Using Model With() With Or Conditions

This has been driving me crazy, and I’ve been all over the forum all day.

I have to add multiple filters to a table, and they will be dynamically generated.

Per Yii documentation, this almost works




$model = Users::model()->with(array(

    'parent' => array(

        'joinType' => 'INNER JOIN',

        'condition' => "parent.city in ('Boston','Chicago')",

    ),

    'child' => array(

        'joinType' => 'INNER JOIN',

        'condition' => 'child.age = 6',

    ),

));



I return this to the page, where it is used in a grid




$this->widget('zii.widgets.grid.CGridView', array(

    'id' => 'users-grid',

    'dataProvider' => $model->search(),

    'filter' => $model,

    'columns' => array(

        'id',

        'first_name',

        'last_name',

        'email',

        'role',

        array(

            'class' => 'CButtonColumn',

        ),

    ),

));          



Like I said, this almost works, but of course, it only returns records where the child is 6 AND the parent is from Boston or Chicago. I need to apply all these filters independently (I will build up the arrays after a form submit), so I need all children who are 6, and all parents who are from those cities, for example (basically, I need to apply "OR" between all the conditions).

I don’t see this in anything I’ve searched for online, and CDbCondition doesn’t work, because I can’t use find, because I have to return the model, not the records (because the grid uses ->search() on the model). But if you get what I’m trying to do, and have a better solution, please point it out.

Any help would be greatly appreciated, and understand, I was handed a full-blown application, and don’t really know Yii (but I do know PHP).

Thank you in advance!

Rory