private static function buildProfileQuery() { $args = func_get_args(); $joinsAndWhere = XDB::prepare($args); return array('SELECT DISTINCT a.uid FROM accounts AS a INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET(\'owner\', perms)) INNER JOIN profiles AS p ON (p.pid = ap.pid) ' . $joinsAndWhere, 'SELECT DISTINCT p.pid FROM profiles AS p ' . $joinsAndWhere); }