Example #1
0
 /**
  * Restores league.
  * 
  * @param Entity\LeagueImpl $leagueModel
  * @return LeagueIterator
  * @throws RDException
  */
 public function restore($leagueModel)
 {
     //echo 'dump lague'.  var_dump($leagueModel);
     $q = 'SELECT * from league WHERE 1=1 ';
     if ($leagueModel != NULL) {
         if ($leagueModel->getName() != NULL) {
             $q .= ' AND league.name = ' . $this->wrap($leagueModel->getName());
         }
         if ($leagueModel->getLeagueRules() != NULL) {
             $q .= ' AND league.league_rules = ' . $this->wrap($leagueModel->getLeagueRules());
         }
         if ($leagueModel->getMatchRules() != NULL) {
             $q .= ' AND league.match_rules = ' . $this->wrap($leagueModel->getMatchRules());
         }
         if ($leagueModel->getIsIndoor() != NULL) {
             $q .= ' AND is_indoor = ' . ($leagueModel->getIsIndoor() ? 1 : 0);
         }
         if ($leagueModel->getMinTeams() != NULL) {
             $q .= ' AND min_teams = ' . $leagueModel->getMinTeams();
         }
         if ($leagueModel->getMaxTeams() != NULL) {
             $q .= ' AND max_teams = ' . $leagueModel->getMaxTeams();
         }
         if ($leagueModel->getMinMembers() != NULL) {
             $q .= ' AND min_members = ' . $leagueModel->getMinMembers();
         }
         if ($leagueModel->getMaxMembers() != NULL) {
             $q .= ' AND max_members = ' . $leagueModel->getMaxMembers();
         }
         if ($leagueModel->getId() != -1) {
             $q .= ' AND league_id = ' . $leagueModel->getId();
         }
     }
     //echo 'league wuery:' . $q;
     $stmt = $this->dbConnection->prepare($q . ';');
     if ($stmt->execute()) {
         //get results from Query
         $resultSet = $stmt->fetchAll(\PDO::FETCH_ASSOC);
         // return iterator
         return new LeagueIterator($resultSet, $this->objLayer);
     } else {
         throw new RDException('Error restoring league model' . print_r($stmt->errorInfo()));
     }
 }
Example #2
0
 /**
  * Team is set as league winner
  *
  * @param Entity\LeagueImpl $league
  * @param Entity\TeamImpl $team
  * @throws RDException is thrown if team is not in the league.
  * @return void
  */
 public function selectLeagueWinner($league, $team)
 {
     if ($team->getParticipatesInLeague()->getName() != $league->getName()) {
         throw new RDException($string = "Team is not in this league.");
     }
     $this->objectLayer->createTeamWinnerOfLeague($team, $league);
 }