Esempio n. 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()));
     }
 }
Esempio n. 2
0
 /**
  * @param \edu\uga\cs\recdawgs\entity\impl\LeagueImpl $league
  * @param int $leagueId
  */
 public function listInfo($league = null, $leagueId = -1)
 {
     $html = "";
     if ($league) {
         $leagueRules = $league->getLeagueRules();
         $matchRules = $league->getMatchRules();
         $minTeams = $league->getMinTeams();
         $maxTeams = $league->getMaxTeams();
         $minPlayers = $league->getMinMembers();
         $maxPlayers = $league->getMaxMembers();
         $location = $league->getIsIndoor() ? "Indoor" : "Outdoor";
         $winner = $league->getWinnerOfLeague() != null ? $league->getWinnerOfLeague()->getName() : "None";
         $html .= "<ul>";
         $html .= "<li>League rules: {$leagueRules}</li>";
         $html .= "<li>Match rules {$matchRules}</li>";
         $html .= "<li>Min Teams: {$minTeams}</li>";
         $html .= "<li>Max Teams: {$maxTeams}</li>";
         $html .= "<li>Min Players per team: {$minPlayers}</li>";
         $html .= "<li>Max Players per team: {$maxPlayers}</li>";
         $html .= "<li>{$location}</li>";
         $html .= "<li>Winner of league: {$winner}</li>";
         $html .= "</ul>";
     } else {
         $league = $this->logicLayer->findLeague(null, $leagueId)->current();
         $leagueRules = $league->getLeagueRules();
         $matchRules = $league->getMatchRules();
         $minTeams = $league->getMinTeams();
         $maxTeams = $league->getMaxTeams();
         $minPlayers = $league->getMinMembers();
         $maxPlayers = $league->getMaxMembers();
         $location = $league->getIsIndoor() ? "Indoor" : "Outdoor";
         $winner = $league->getWinnerOfLeague() != null ? $league->getWinnerOfLeague()->getName() : "None";
         $html .= "<ul>";
         $html .= "<li>League rules: {$leagueRules}</li>";
         $html .= "<li>Match rules: {$matchRules}</li>";
         $html .= "<li>Min Teams: {$minTeams}</li>";
         $html .= "<li>Max Teams: {$maxTeams}</li>";
         $html .= "<li>Min Players per team: {$minPlayers}</li>";
         $html .= "<li>Max Players per team: {$maxPlayers}</li>";
         $html .= "<li>{$location}</li>";
         $html .= "<li>Winner of league: {$winner}</li>";
         $html .= "</ul>";
     }
     return $html;
 }