Beispiel #1
0
 public function create(StudentDTO $student)
 {
     $connection = $this->db->getConn();
     $exists = 'SELECT id FROM students LIMIT 1';
     $isValid = $this->validate($_POST);
     if ($isValid['state']) {
         $sql = "INSERT INTO students(firstname, lastname, age, bday, email, sex, comment) VALUES ('" . $student->getFirstname() . "', '" . $student->getLastname() . "', '" . $student->getAge() . "', '" . $student->getBirthday() . "', '" . $student->getEmail() . "', '" . $student->getSex() . "', '" . $student->getAbout() . "')";
         $result = $connection->query($sql);
         if ($result !== true) {
             echo mysqli_errno($connection) . ": " . mysqli_error($connection) . "\n";
         }
     }
     return $isValid;
 }