Created
January 21, 2010 02:55
-
-
Save tjboudreaux/282539 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function findLeadersBySchool($schoolId = 1, $limit = 3) | |
{ | |
return $this->findLeadersBaseQuery() | |
->leftJoin('u.Assignment_Assignee a ON u.id = a.assigned_entity_id ') | |
->addWhere('a.assigned_entity_type = ?', User_Model_Student::ENTITY_TYPE) | |
->addWhere('a.assignee_entity_type = ?', Plan_Model_Classroom::ENTITY_TYPE) | |
->addWhere('a.assignee_entity_id = ?', $schoolId) | |
//->limit($limit) | |
->execute(); | |
} | |
public function findLeadersBaseQuery() | |
{ | |
return $this->getTable() | |
->createQuery() | |
->select("SUM(c2.steps_per_minute * c.minutes) AS steps, u.username as username") | |
->from("Challenge_Model_ActivityLog c") | |
->leftJoin("c.Challenge_Activity c2") | |
->leftJoin("c.Challenge_Profile c3") | |
->leftJoin("c3.User_Student u"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment