示例#1
0
 /**
  * Deletes winner.
  *
  * @param Entity\TeamImpl $team
  * @param Entity\LeagueImpl $league
  * @throws RDException
  */
 public function deleteWinner($team, $league)
 {
     $q = 'DELETE FROM is_winner_of WHERE team_id = ? AND league_id = ?;';
     //create Prepared statement
     $stmt = $this->dbConnection->prepare($q);
     //bind parameter to query
     $teamId = $team->getId();
     $leagueId = $league->getId();
     $stmt->bindParam(1, $teamId, \PDO::PARAM_INT);
     $stmt->bindParam(2, $leagueId, \PDO::PARAM_INT);
     //execute query
     if ($stmt->execute()) {
         echo 'link deleted successfully';
     } else {
         throw new RDException('Deletion of link unsuccessful');
     }
 }
示例#2
0
 /**
  * Restores winner of league.
  * 
  * @param Entity\TeamImpl $team
  * @return Entity\LeagueImpl
  * @throws RDException
  */
 public function restoreLeagueWinnerOf($team)
 {
     if ($team == null) {
         throw new RDException('Team parameter is null');
     }
     $q = 'SELECT * from league WHERE league_id = (SELECT league_id FROM league_team WHERE team_id = ? LIMIT 1);';
     $stmt = $this->dbConnection->prepare($q);
     $teamID = $team->getId();
     $stmt->bindParam(1, $teamID, \PDO::PARAM_INT);
     if ($stmt->execute()) {
         //get results from Query
         $resultSet = $stmt->fetchAll(\PDO::FETCH_ASSOC);
         // return first obj
         return (new LeagueIterator($resultSet, $this->objLayer))->current();
     } else {
         throw new RDException('Error restoring league');
     }
 }