Skip to content

Instantly share code, notes, and snippets.

@tjboudreaux
Created January 21, 2010 02:55
Show Gist options
  • Save tjboudreaux/282539 to your computer and use it in GitHub Desktop.
Save tjboudreaux/282539 to your computer and use it in GitHub Desktop.
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