/** * Retrieves zero or more rows from table 'language' satisfying some criteria * * This function returns zero or more rows from the wrapped table that satisfy the given criteria. All attributes * are returned. * * This function overrides AR_Model::get_rows(). It can also accept 'contest_id' as a criteria key; i.e., the * contest IDs that this language is allowed in. * * @param array $criteria An array of <attribute-name> => <attribute-value> pairs. Only rows that satisfy all * criteria will be retrieved. * @param array $conditions An array of zero or more of the following pairs: * - 'limit' => The maximum number of rows to be retrieved. * - 'offset' => The starting number of the rows to be retrieved. * - 'order_by' => The resulting rows order as an array of zero or more * <attribute-name> => ('ASC' | 'DESC') pairs. * * @return array Zero or more rows that satisfies the criteria as an array of <row-ID> => <row>. */ public function get_rows($criteria = array(), $conditions = array()) { if (isset($criteria['contest_id'])) { $this->db->join('contest_language', 'contest_language.language_id=id'); $this->db->where('contest_language.contest_id', $criteria['contest_id']); } return parent::get_rows($criteria, $conditions); }
/** * Retrieves zero or more rows from table 'category' satisfying some criteria * * This function returns zero or more rows from the wrapped table that satisfy the given criteria. All attributes * are returned. * * This function overrides AR_Model::get_rows(). It can also accept 'contest_id' as a criteria key; i.e., the * contest IDs that this category can compete in. * * @param array $criteria An array of <attribute-name> => <attribute-value> pairs. Only rows that satisfy all * criteria will be retrieved. * @param array $conditions An array of zero or more of the following pairs: * - 'limit' => The maximum number of rows to be retrieved. * - 'offset' => The starting number of the rows to be retrieved. * - 'order_by' => The resulting rows order as an array of zero or more * <attribute-name> => ('ASC' | 'DESC') pairs. * * @return array Zero or more rows that satisfies the criteria as an array of <row-ID> => <row>. */ public function get_rows($criteria = array(), $conditions = array()) { if (isset($criteria['contest_id'])) { $this->db->join('contest_member', 'contest_member.category_id=id'); $this->db->where('contest_member.contest_id', $criteria['contest_id']); } return parent::get_rows($criteria, $conditions); }
/** * Retrieves zero or more rows from table 'problem' satisfying some criteria * * This function returns zero or more rows from the wrapped table that satisfy the given criteria. All attributes * are returned. * * This function overrides AR_Model::get_rows(). It can also accept 'contest_id' as a criteria key; i.e., the * contest IDs that this problem is assigned. * * @param array $criteria An array of <attribute-name> => <attribute-value> pairs. Only rows that satisfy all * criteria will be retrieved. * @param array $conditions An array of zero or more of the following pairs: * - 'limit' => The maximum number of rows to be retrieved. * - 'offset' => The starting number of the rows to be retrieved. * - 'order_by' => The resulting rows order as an array of zero or more * <attribute-name> => ('ASC' | 'DESC') pairs. * * @return array Zero or more rows that satisfies the criteria as an array of <row-ID> => <row>. */ public function get_rows($criteria = array(), $conditions = array()) { if (isset($criteria['contest_id'])) { $this->db->select('id, name, author, time_limit, memory_limit, alias'); $this->db->join('contest_problem', 'contest_problem.problem_id=id'); $this->db->where('contest_problem.contest_id', $criteria['contest_id']); } else { $this->db->select('problem.id AS id, name, author, time_limit, memory_limit, COUNT(testcase.id) AS tc_count'); $this->db->join('testcase', 'testcase.problem_id=problem.id', 'left outer'); $this->db->group_by('problem.id'); } return parent::get_rows($criteria, $conditions); }
/** * Retrieves zero or more rows from table 'clarification' satisfying some criteria * * This function returns zero or more rows from the wrapped table that satisfy the given criteria. All attributes * are returned. * * If there is 'clarification.user_id' in $criteria, the rows with user_id=1 will be also returned. * * @param array $criteria An array of <attribute-name> => <attribute-value> pairs. Only rows that satisfy all * criteria will be retrieved. * @param array $conditions An array of zero or more of the following pairs: * - 'limit' => The maximum number of rows to be retrieved. * - 'offset' => The starting number of the rows to be retrieved. * - 'order_by' => The resulting rows order as an array of zero or more * <attribute-name> => ('ASC' | 'DESC') pairs. * * @return array Zero or more rows that satisfies the criteria as an array of <row-ID> => <row>. */ public function get_rows_with_admin($criteria = array(), $conditions = array()) { $this->db->select('clarification.id AS id, user_id, clarification.contest_id, clar_time, title, (answer IS NOT NULL) AS answered, user.name AS user_name, contest.name AS contest_name'); $this->db->join('contest', 'contest.id=contest_id'); $this->db->join('user', 'user.id=user_id', 'left outer'); if (isset($criteria['clarification.user_id'])) { $this->db->where('(user_id=1 OR user_id=' . $criteria['clarification.user_id'] . ')'); unset($criteria['clarification.user_id']); } return parent::get_rows($criteria, $conditions); }
/** * Retrieves zero or more rows from table 'submission' satisfying some criteria * * This function returns zero or more rows from the wrapped table that satisfy the given criteria. All attributes * are returned. * * This function overrides AR_Model::get_rows(). * * @param array $criteria An array of <attribute-name> => <attribute-value> pairs. Only rows that satisfy all * criteria will be retrieved. * @param array $conditions An array of zero or more of the following pairs: * - 'limit' => The maximum number of rows to be retrieved. * - 'offset' => The starting number of the rows to be retrieved. * - 'order_by' => The resulting rows order as an array of zero or more * <attribute-name> => ('ASC' | 'DESC') pairs. * * @return array Zero or more rows that satisfies the criteria as an array of <row-ID> => <row>. */ public function get_rows($criteria = array(), $conditions = array()) { $this->db->select('submission.id AS id, user_id, submission.contest_id, submission.problem_id, language_id, submit_time, start_judge_time, end_judge_time, verdict, user.name AS user_name, contest.name AS contest_name, problem.name AS problem_name, language.name AS language_name, alias AS problem_alias'); $this->db->join('contest', 'contest.id=contest_id'); $this->db->join('problem', 'problem.id=problem_id'); $this->db->join('user', 'user.id=user_id'); $this->db->join('language', 'language.id=language_id'); $this->db->join('contest_problem', 'contest_problem.contest_id=submission.contest_id AND contest_problem.problem_id=submission.problem_id'); return parent::get_rows($criteria, $conditions); }
/** * Retrieves zero or more rows from table 'problem' satisfying some criteria * * This function returns zero or more rows from the wrapped table that satisfy the given criteria. All attributes * are returned. * * This function overrides AR_Model::get_rows(). * * @param array $criteria An array of <attribute-name> => <attribute-value> pairs. Only rows that satisfy all * criteria will be retrieved. * @param array $conditions An array of zero or more of the following pairs: * - 'limit' => The maximum number of rows to be retrieved. * - 'offset' => The starting number of the rows to be retrieved. * - 'order_by' => The resulting rows order as an array of zero or more * <attribute-name> => ('ASC' | 'DESC') pairs. * * @return array Zero or more rows that satisfies the criteria as an array of <row-ID> => <row>. */ public function get_rows($criteria = array(), $conditions = array()) { $this->db->select('user.id, user.name, username, password, institution, category_id, category.name AS category_name, last_activity'); $this->db->join('category', 'category.id=category_id'); return parent::get_rows($criteria, $conditions); }