/** * Adds student as member of team. * * @param Entity\AdministratorImpl $student * @param Entity\TeamImpl $team * @throws RDException */ public function storeStudentMemberOf($student, $team) { $q = 'INSERT INTO is_member_of (user_id, team_id) VALUES(?, ?);'; $stmt = $this->dbConnection->prepare($q); $studentID = $student->getId(); $teamID = $team->getId(); $stmt->bindParam(1, $studentID, \PDO::PARAM_INT); $stmt->bindParam(2, $teamID, \PDO::PARAM_INT); if ($stmt->execute()) { echo "\n {$student->getFirstName()} {$student->getLastName()} successfully added as team member of: " . $team->getName(); } else { throw new RDException($student->getUserName() . ' unsuccessfully added as team member of: ' . $team->getName()); } }
/** * Deletes an Admin or Student from db. * * @param Entity\AdministratorImpl $user * @throws RDException */ public function delete($user) { if ($user->getId() == -1) { //if user isn't persistent, we are done return; } //Prepare mySQL query $q = 'DELETE FROM ' . DB_NAME . '.user WHERE user_id = ?;'; //create Prepared statement $stmt = $this->dbConnection->prepare($q); //bind parameter to query $persistenceId = $user->getId(); $stmt->bindParam(1, $persistenceId, \PDO::PARAM_INT); //execute query if ($stmt->execute()) { echo 'User deleted successfully'; } else { throw new RDException('Deletion of User successful'); } }