/** * Retrieve this action's profiles * * @return Profile $profile Profile query results */ function getProfiles() { $ufp = new User_flag_profile(); $ufp->selectAdd(); $ufp->selectAdd('profile_id'); $ufp->selectAdd('count(*) as flag_count'); $ufp->whereAdd('cleared is NULL'); $ufp->groupBy('profile_id'); $ufp->orderBy('flag_count DESC, profile_id DESC'); $offset = ($this->page - 1) * PROFILES_PER_PAGE; $limit = PROFILES_PER_PAGE + 1; $ufp->limit($offset, $limit); $profiles = array(); if ($ufp->find()) { while ($ufp->fetch()) { $profile = Profile::staticGet('id', $ufp->profile_id); if (!empty($profile)) { $profiles[] = $profile; } } } $ufp->free(); return new ArrayWrapper($profiles); }