コード例 #1
0
 public function validateStudent(Student $student)
 {
     $errors = [];
     $errors['firstName'] = $this->validateName($student->getFirstName());
     $errors['lastName'] = $this->validateName($student->getLastName());
     $errors['gender'] = $this->validateGender($student->getGender());
     $errors['group'] = $this->validateGroup($student->getGroup());
     $errors['email'] = $this->confirmEmail($student->getEmail(), $student->getToken());
     $errors['birthYear'] = $this->validateBirthYear($student->getBirthYear());
     $errors['status'] = $this->validateStatus($student->getStatus());
     $errors['rating'] = $this->validateRating($student->getRating());
     return array_filter($errors, [$this, 'filterErrors']);
 }
コード例 #2
0
 /**
  * Updates given Student entity in the database.
  *
  * @param Student $student Student entity to update.
  */
 public function updateStudent(Student $student)
 {
     $query = $this->pdo->prepare("UPDATE students SET name = :name_bind, surname = :surname_bind, " . "gender = :gender_bind, sgroup = :sgroup_bind, email = :email_bind, byear = :byear_bind, status = :status_bind, " . "rating = :rating_bind WHERE token = :token_bind");
     $query->bindValue(':token_bind', $student->getToken(), \PDO::PARAM_STR);
     $query->bindValue(':name_bind', $student->getFirstName(), \PDO::PARAM_STR);
     $query->bindValue(':surname_bind', $student->getLastName(), \PDO::PARAM_STR);
     $query->bindValue(':gender_bind', $student->getGender(), \PDO::PARAM_STR);
     $query->bindValue(':sgroup_bind', $student->getGroup(), \PDO::PARAM_STR);
     $query->bindValue(':email_bind', $student->getEmail(), \PDO::PARAM_STR);
     $query->bindValue(':byear_bind', $student->getBirthYear(), \PDO::PARAM_INT);
     $query->bindValue(':status_bind', $student->getStatus(), \PDO::PARAM_STR);
     $query->bindValue(':rating_bind', $student->getRating(), \PDO::PARAM_INT);
     $query->execute();
 }