You can still build this statement with CDbCriteria, I think ... something like:
$criteria=new CDbCriteria;
$criteria->condition = '
(
(
userId = 1 OR
userId IN (SELECT userId FROM follower WHERE followerId = 1)
)
AND activityType IN(1, 2, 3)
)
OR (
targetId = 24
AND aType IN(1, 2, 3, 4, 5)
)
';
$criteria->order = 'id DESC';
$results=Activity::model()->findAll($criteria);
As this point, you can simply write a regular SQL query, but there may be some advantages to this: parameter binding, merging criteria, adding additional criteria, etc.
source
share