/** * @param PitcherObject $pitcherObject */ public function update($pitcherObject) { $oldData = $this->read($pitcherObject->getId()); $this->players_id = $pitcherObject->getPlayersId() !== null ? parent::cleanData($pitcherObject->getPlayersId()) : $oldData->getPlayersId(); $this->win = $pitcherObject->getWin() !== null ? parent::cleanData($pitcherObject->getWin()) : $oldData->getWin(); $this->loss = $pitcherObject->getLoss() !== null ? parent::cleanData($pitcherObject->getLoss()) : $oldData->getLoss(); $this->era = $pitcherObject->getEra() !== null ? parent::cleanData($pitcherObject->getEra()) : $oldData->getEra(); $this->innings_pitched = $pitcherObject->getInningsPitched() !== null ? parent::cleanData($pitcherObject->getInningsPitched()) : $oldData->getInningsPitched(); $this->runs_allowed = $pitcherObject->getRunsAllowed() !== null ? parent::cleanData($pitcherObject->getRunsAllowed()) : $oldData->getRunsAllowed(); $this->earned_runs_allowed = $pitcherObject->getEarnedRunsAllowed() !== null ? parent::cleanData($pitcherObject->getEarnedRunsAllowed()) : $oldData->getEarnedRunsAllowed(); $this->walks_allowed = $pitcherObject->getWalksAllowed() !== null ? parent::cleanData($pitcherObject->getWalksAllowed()) : $oldData->getWalksAllowed(); $this->strike_outs = $pitcherObject->getStrikeOuts() !== null ? parent::cleanData($pitcherObject->getStrikeOuts()) : $oldData->getStrikeOuts(); $this->updateStatement->execute(); }
/** * Created by PhpStorm. * User: Greg * Date: 10/12/2015 * Time: 5:56 PM */ include "Database/db.php"; include "Database/Tables/PlayersTable.php"; include "Database/Tables/BatterStatsTable.php"; include "Database/Tables/PollsTable.php"; include "Database/Tables/AdminsTable.php"; include "Database/Tables/EventsTable.php"; include "Database/Tables/PitcherStatsTable.php"; $pitcherTable = new PitcherStatsTable(); $pitcherObject = new PitcherObject(); $pitcherObject->setWin(3); $pitcherObject->setLoss(2); $pitcherObject->setInningsPitched(22); $pitcherObject->setRunsAllowed(12); $pitcherObject->setEarnedRunsAllowed(10); $pitcherObject->setWalksAllowed(4); $pitcherObject->setStrikeOuts(12); $pitcherObject->calcEra(); $pitcherTable->create($pitcherObject); /*$eventsTable = new EventsTable(); $eventsObject = new EventsObject(); $eventsObject->setName("Bob"); $eventsObject->setDescription("Bob is a great man and I hope he has a great life."); $eventsObject->setImage("ImageGoesHere");