public static function get(User $user) { global $db; $user_id = $user->getID(); $query = "SELECT * FROM `student_contributions` WHERE `user_id` = " . $db->qstr($user_id) . " ORDER BY `start_year` DESC, `start_month` DESC"; $results = $db->getAll($query); $contributions = array(); if ($results) { foreach ($results as $result) { $contribution = Contribution::fromArray($result); $contributions[] = $contribution; } } return new self($contributions); }
/** * * @param int $id * @return Contribution */ public static function get($id) { global $db; $query = "SELECT * FROM `student_contributions` WHERE `id` = " . $db->qstr($id); $result = $db->getRow($query); if ($result) { $contribution = Contribution::fromArray($result); return $contribution; } }