Exemplo n.º 1
0
 /**
  * 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());
     }
 }
Exemplo n.º 2
0
 /**
  * Restores Administrator in database.
  *
  * @param Entity\AdministratorImpl $modelAdministrator
  * @return AdministratorIterator
  * @throws RDException
  */
 public function restoreAdministrator($modelAdministrator)
 {
     $q = 'SELECT * from ' . DB_NAME . '.user WHERE user.user_type = 1';
     if ($modelAdministrator != NULL) {
         if ($modelAdministrator->getFirstName() != NULL) {
             $q .= ' AND first_name = ' . $modelAdministrator->getFirstName();
         }
         if ($modelAdministrator->getLastName() != NULL) {
             $q .= ' AND last_name = ' . $modelAdministrator->getLastName();
         }
         if ($modelAdministrator->getUserName() != NULL) {
             $q .= ' AND user.user_name = "' . $modelAdministrator->getUserName() . '"';
         }
         if ($modelAdministrator->getPassword() != NULL) {
             $q .= ' AND password = '******' AND email_address = ' . $modelAdministrator->getEmailAddress();
         }
         if ($modelAdministrator->getId() != -1) {
             $q .= ' AND user_id = ' . $modelAdministrator->getId();
         }
     }
     $stmt = $this->dbConnection->prepare($q . ';');
     if ($stmt->execute()) {
         //get results from Query
         $resultSet = $stmt->fetchAll(\PDO::FETCH_ASSOC);
         // return iterator
         return new AdministratorIterator($resultSet, $this->objLayer);
     } else {
         throw new RDException('Error restoring administrator model error:' . print_r($stmt->errorInfo()));
     }
 }