I’m implementing a search page in a social netwrking app, and I want to do a global search for whether a user or one of its related attributes contain the specified search term.
Basically, I want the combined result of the following RAR queries:
User::model()->with(array('field_values'=>array('condition'=>'value LIKE :term', 'params'=>array('term'=>'%'.$model->term.'%'))))->findAll(); User::model()->findAll(array('condition'=>'name LIKE :term', 'params'=>array('term'=>'%'.$model->term.'%')));
Is it possible to combine these two queries into one? Later on I need to search for even more properties and it seems a bit overkill to me to have to do each of these queries separately, when it could be achieved using a simple ‘OR’ operator in a native SQL query.