/**
  * Creates a new ViewableContest object.
  *
  * @param	integer		$sponsorID
  * @param 	array<mixed>	$row
  */
 public function __construct($sponsorID, $row = null)
 {
     if ($sponsorID !== null) {
         $sql = "SELECT\t\tavatar_table.*, \n\t\t\t\t\t\tcontest_sponsor.*,\n\t\t\t\t\t\tuser_table.username, \n\t\t\t\t\t\tgroup_table.groupName\n\t\t\t\tFROM \t\twcf" . WCF_N . "_contest_sponsor contest_sponsor\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\tWHERE \t\tcontest_sponsor.sponsorID = " . intval($sponsorID) . "\n\t\t\t\tAND\t\t(" . ContestSponsor::getStateConditions() . ")";
         $row = WCF::getDB()->getFirstRow($sql);
     }
     DatabaseObject::__construct($row);
 }
 /**
  * @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_sponsor.*,\n\t\t\t\t\tuser_table.username, \n\t\t\t\t\tgroup_table.groupName\n\t\t\tFROM\t\twcf" . WCF_N . "_contest_sponsor contest_sponsor\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 . "_avatar avatar_table\n\t\t\tON\t\t(avatar_table.avatarID = user_table.avatarID)\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\t" . $this->sqlJoins . "\n\n\t\t\tWHERE (" . ContestSponsor::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->sponsors[] = new ViewableContestSponsor(null, $row);
     }
 }
 /**
  * @see DatabaseObjectList::countObjects()
  */
 public function countObjects()
 {
     $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twcf" . WCF_N . "_contest_sponsor contest_sponsor\n\n\t\t\tWHERE (" . ContestSponsor::getStateConditions() . ")\n\t\t\t" . (!empty($this->sqlConditions) ? "AND " . $this->sqlConditions : '');
     $row = WCF::getDB()->getFirstRow($sql);
     return $row['count'];
 }