/** * The SQL Query preparation combined with Query_Execute * * @version 1 * @author Rick de Man <*****@*****.**> * * @param string $Query * The Query to be executed * @param string $Comment * The Comment for the Query, for Debug use */ public function Query_Prepare($Query, $Comment) { // The SQL must be free to continue if ($this->SQL_Free !== true) { $this->Query_Next(); } // SQL is occupied $this->SQL_Free = false; // Replace Table tag $Query = $this->Query_Table_Preg($Query); // Prepare the Query $this->STH = $this->DBH->Prepare($Query); // Load the Backtrace $Trace = debug_backtrace(); // Create a SQL Log Event $this->Log = array('F' => $Trace[0]['file'] . ':' . $Trace[0]['line'] . '(' . $Trace[1]['function'] . ')', 'Q' => $Query, 'P' => array(), 'C' => $Comment); }
/** * updates this Crew in mySQL * * @param \PDO $pdo PDO connection object * @throws \PDOException when mySQL related errors occur * @throws \TypeError if $pdo is not a PDO connection object **/ public function update(\PDO $pdo) { //enforce the crewID is not null (i.e., don't update a crew that hasn't been inserted) if ($this->crewId === null) { throw new \PDOException("unable to update a crew that does not exist"); } //create query template $query = "UPDATE crew SET crewCompanyId = :crewCompanyId, crewLocation = :crewLocation WHERE crewId = :crewId"; $statement = $pdo->Prepare($query); //bind the member variable to the place holder in the template $parameters = ["crewId" => $this->crewId, "crewCompanyId" => $this->crewCompanyId, "crewLocation" => $this->crewLocation]; $statement->execute($parameters); }
/** * updates this Shift in mySQL * * @param \PDO $pdo PDO connection object * @throws \PDOException when mySQL related errors occur * @throws \TypeError if $pdo is not a PDO connection object **/ public function update(\PDO $pdo) { //enforce the shiftId is not null (i.e., don't update a shift that hasn't been inserted) if ($this->shiftId === null) { throw new \PDOException("unable to update a shift that does not exist"); } //create query template $query = "UPDATE shift SET shiftUserId = :shiftUserId, shiftCrewId = :shiftCrewId, shiftRequestId = :shiftRequestId, shiftStartTime = :shiftStartTime, shiftDuration = :shiftDuration, shiftDate = :shiftDate, shiftDelete = :shiftDelete WHERE shiftId = :shiftId"; $statement = $pdo->Prepare($query); //bind the member variables to the place holders in the template $sDate = $this->shiftDate->format("Y-m-d"); $parameters = ["shiftUserId" => $this->shiftUserId, "shiftCrewId" => $this->shiftCrewId, "shiftRequestId" => $this->shiftRequestId, "shiftStartTime" => $this->shiftStartTime, "shiftDuration" => $this->shiftDuration, "shiftDate" => $sDate, "shiftDelete" => $this->shiftDelete, "shiftId" => $this->shiftId]; $statement->execute($parameters); }