/** * creates sports venue * * @param Entity\SportsVenueImpl $sportsVenue * @throws RDException */ public function save($sportsVenue) { if ($sportsVenue->isPersistent()) { //update $q = "UPDATE sports_venue\n set sports_venue.name = ?,\n address = ?,\n is_indoor = ?\n WHERE sports_venue_id = ?;"; //create prepared statement from query $stmt = $this->dbConnection->prepare($q); //bind parameters to prepared statement $sportsVenueName = $sportsVenue->getName(); $address = $sportsVenue->getAddress(); $isIndoor = $sportsVenue->getIsIndoor() ? 1 : 0; $sportsVenueId = $sportsVenue->getId(); $stmt->bindParam(1, $sportsVenueName, \PDO::PARAM_STR); $stmt->bindParam(2, $address, \PDO::PARAM_STR); $stmt->bindParam(3, $isIndoor, \PDO::PARAM_INT); $stmt->bindParam(4, $sportsVenueId, \PDO::PARAM_INT); if ($stmt->execute()) { echo 'venue created successfully'; } else { throw new RDException('Error creating venue'); } } else { //insert //create Query $q = "INSERT INTO sports_venue (sports_venue.name, address, is_indoor) VALUES(?, ?, ?);"; //create prepared statement from query $stmt = $this->dbConnection->prepare($q); //bind parameters to prepared statement $sportsVenueName = $sportsVenue->getName(); $address = $sportsVenue->getAddress(); $isIndoor = $sportsVenue->getIsIndoor() ? 1 : 0; $stmt->bindParam(1, $sportsVenueName, \PDO::PARAM_STR); $stmt->bindParam(2, $address, \PDO::PARAM_STR); $stmt->bindParam(3, $isIndoor, \PDO::PARAM_INT); if ($stmt->execute()) { $sportsVenue->setId($this->dbConnection->lastInsertId()); echo 'venue created successfully'; } else { throw new RDException('venue creating match'); } } }
include '/Users/montanawong/Sites/RecDawgs/src/' . str_replace('\\', '/', $class_name) . '.php'; }); use edu\uga\cs\recdawgs\presentation as Presentation; use edu\uga\cs\recdawgs\entity\impl as Entity; if (!isset($_POST) || !isset($_POST['sportsVenueId'])) { $errorMsg = urlencode("Sports Venue not found."); header("Location: sportsVenues.php?status={$errorMsg}"); } ?> <body> <div class="container"> <?php $sportsVenueId = $_POST['sportsVenueId']; $sportsVenueModel = new Entity\SportsVenueImpl(); $sportsVenueModel->setId($sportsVenueId); $sportsVenueUI = new Presentation\SportsVenueUI(); echo $sportsVenueUI->listSportsVenueInfo($sportsVenueModel); echo "<h2>Leagues used in</h2>"; echo $sportsVenueUI->listLeaguesUsedIn(null, $sportsVenueId); ?> <br/><br/> <?php //if admin allow update and deletion of sports venues and assignment to league if ($_SESSION['userType'] == 1) { echo $sportsVenueUI->listAddToLeagueButton($sportsVenueId); echo "<h3>Update Sports Venue</h3><br/><form action = 'updateSportsVenue.php' method = 'post' >\n <input type = 'hidden' name = 'sportsVenueId' value = '{$sportsVenueId}'>\n <input type ='submit' value ='Update the Sports Venue'>\n</form >"; } if ($_SESSION['userType'] == 1) { /* echo "<h3>Delete Sports Venue</h3><br/><form action = 'php/doDeleteSportsVenue.php' method = 'post'>