/** * @see DatabaseObjectList::readObjects() */ public function readObjects() { $sql = "SELECT\t\t" . (!empty($this->sqlSelects) ? $this->sqlSelects . ',' : '') . "\n\t\t\t\t\tavatar_table.*,\n\t\t\t\t\tcontest_price.*,\n\t\t\t\t\tuser_table.username,\n\t\t\t\t\tuser_table.disableAvatar, \n\t\t\t\t\tuser_table.avatarID, \n\t\t\t\t\tuser_table.gravatar,\n\t\t\t\t\tgroup_table.groupName,\n\t\t\t\t\tcontest_sponsor.userID,\n\t\t\t\t\tcontest_sponsor.groupID,\n\t\t\t\t\tuser_table_winner.userID AS winner_userID,\n\t\t\t\t\tuser_table_winner.username AS winner_username,\n\t\t\t\t\tgroup_table_winner.groupID AS winner_groupID,\n\t\t\t\t\tgroup_table_winner.groupName AS winner_groupName,\n\t\t\t\t\tavatar_table_winner.avatarID AS winner_avatarID,\n\t\t\t\t\tavatar_table_winner.avatarCategoryID AS winner_avatarCategoryID,\n\t\t\t\t\tavatar_table_winner.avatarName AS winner_avatarName,\n\t\t\t\t\tavatar_table_winner.avatarExtension AS winner_avatarExtension,\n\t\t\t\t\tavatar_table_winner.width AS winner_width,\n\t\t\t\t\tavatar_table_winner.height AS winner_height\n\t\t\tFROM \t\twcf" . WCF_N . "_contest_price contest_price\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_contest_sponsor contest_sponsor\n\t\t\tON\t\t(contest_sponsor.sponsorID = contest_price.sponsorID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user_table\n\t\t\tON\t\t(user_table.userID = contest_sponsor.userID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_group group_table\n\t\t\tON\t\t(group_table.groupID = contest_sponsor.groupID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_avatar avatar_table\n\t\t\tON\t\t(avatar_table.avatarID = user_table.avatarID)\n\t\t\t\t\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_contest_solution contest_solution\n\t\t\tON\t\t(contest_solution.solutionID = contest_price.solutionID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_contest_participant contest_participant\n\t\t\tON\t\t(contest_participant.participantID = contest_solution.participantID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user_table_winner\n\t\t\tON\t\t(user_table_winner.userID = contest_participant.userID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_avatar avatar_table_winner\n\t\t\tON\t\t(avatar_table_winner.avatarID = user_table_winner.avatarID)\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_group group_table_winner\n\t\t\tON\t\t(group_table_winner.groupID = contest_participant.groupID)\n\t\t\t" . $this->sqlJoins . "\n\n\t\t\tWHERE (" . ContestPrice::getStateConditions() . ")\n\t\t\t" . (!empty($this->sqlConditions) ? "AND " . $this->sqlConditions : '') . "\n\t\t\t" . (!empty($this->sqlOrderBy) ? "ORDER BY " . $this->sqlOrderBy : ''); $result = WCF::getDB()->sendQuery($sql, $this->sqlLimit, $this->sqlOffset); while ($row = WCF::getDB()->fetchArray($result)) { $this->prices[] = new ViewableContestPrice(null, $row); } }
/** * Creates a new ViewableContest object. * * @param integer $priceID * @param array<mixed> $row */ public function __construct($priceID, $row = null) { if ($priceID !== null) { $sql = "SELECT\t\t\n\t\t\t\t\t\tavatar_table.*, \n\t\t\t\t\t\tcontest_price.*,\n\t\t\t\t\t\tuser_table.username, \n\t\t\t\t\t\tcontest_sponsor.userID, \n\t\t\t\t\t\tcontest_sponsor.groupID, \n\t\t\t\t\t\tgroup_table.groupName,\n\t\t\t\t\t\tuser_table_winner.userID AS winner_userID,\n\t\t\t\t\t\tuser_table_winner.username AS winner_username,\n\t\t\t\t\t\tgroup_table_winner.groupID AS winner_groupID,\n\t\t\t\t\t\tgroup_table_winner.groupName AS winner_groupName,\n\t\t\t\t\t\tavatar_table_winner.avatarID AS winner_avatarID,\n\t\t\t\t\t\tavatar_table_winner.avatarCategoryID AS winner_avatarCategoryID,\n\t\t\t\t\t\tavatar_table_winner.avatarName AS winner_avatarName,\n\t\t\t\t\t\tavatar_table_winner.avatarExtension AS winner_avatarExtension,\n\t\t\t\t\t\tavatar_table_winner.width AS winner_width,\n\t\t\t\t\t\tavatar_table_winner.height AS winner_height\n\t\t\t\tFROM \t\twcf" . WCF_N . "_contest_price contest_price\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_contest_sponsor contest_sponsor\n\t\t\t\tON\t\t(contest_sponsor.sponsorID = contest_price.sponsorID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user_table\n\t\t\t\tON\t\t(user_table.userID = contest_sponsor.userID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_avatar avatar_table\n\t\t\t\tON\t\t(avatar_table.avatarID = user_table.avatarID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_group group_table\n\t\t\t\tON\t\t(group_table.groupID = contest_sponsor.groupID)\n\t\t\t\t\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_contest_solution contest_solution\n\t\t\t\tON\t\t(contest_solution.solutionID = contest_price.solutionID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_contest_participant contest_participant\n\t\t\t\tON\t\t(contest_participant.participantID = contest_solution.participantID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user_table_winner\n\t\t\t\tON\t\t(user_table_winner.userID = contest_participant.userID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_avatar avatar_table_winner\n\t\t\t\tON\t\t(avatar_table_winner.avatarID = user_table_winner.avatarID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_group group_table_winner\n\t\t\t\tON\t\t(group_table_winner.groupID = contest_participant.groupID)\n\t\t\t\t\n\t\t\t\tWHERE \t\tcontest_price.priceID = " . intval($priceID) . "\n\t\t\t\tAND\t\t(" . ContestPrice::getStateConditions() . ")"; $row = WCF::getDB()->getFirstRow($sql); } DatabaseObject::__construct($row); }
/** * @see DatabaseObjectList::countObjects() */ public function countObjects() { $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twcf" . WCF_N . "_contest_price contest_price\n\n\t\t\tWHERE (" . ContestPrice::getStateConditions() . ")\n\t\t\t" . (!empty($this->sqlConditions) ? "AND " . $this->sqlConditions : ''); $row = WCF::getDB()->getFirstRow($sql); return $row['count']; }