SELECT * FROM `oc_activity` WHERE ( `affecteduser` = ? ) AND ( `type` IN (...) ) AND ( ( ( `app` = ? ) ) ) AND ( `timestamp` <= ? ) AND ( `activity_id` < ? ) ORDER BY `timestamp` DESC , `activity_id` DESC LIMIT ?