I’m trying the next:
$criteria = new CDbCriteria();
$criteria->compare('t.title',$searchQuery, true, 'OR');
$criteria->compare('t.description',$searchQuery, true, 'OR');
$criteria->with = array(
'author'=>array(
'condition'=>'author.firstname LIKE :query OR
author.lastname LIKE :query',
'params'=>array(':query'=>'%'.strtr($searchQuery,array('%'=>'\%', '_'=>'\_', '\\'=>'\\\\')).'%')
),
);
This code generates query like:
... WHERE ((t.title LIKE :query) OR (t.description LIKE :query)) [b]AND[/b]
(author.firstname LIKE :query OR author.lastname LIKE :query) ....
How to change highlighted AND to OR ?
The construction like this, is not working:
$criteria->with = array(
'author'=>array(
'condition'=>'author.firstname LIKE :query OR
author.lastname LIKE :query',
'params'=>array(':query'=>'%'.strtr($searchQuery,array('%'=>'\%', '_'=>'\_', '\\'=>'\\\\')).'%')
),
[b] 'operator'=>'OR',[/b]
);
In other words, how to change operators AND which Yii places in WHERE for JOIN tables?