示例#1
0
 public function actionUpdate($id)
 {
     $studentManager = new StudentManager();
     $studentUpdate = $studentManager->update($id);
     if ($_POST) {
         $student = new StudentDTO();
         $student->setFirstname($_POST['firstname']);
         $student->setLastname($_POST['lastname']);
         $student->setAge($_POST['age']);
         $student->setBirthday($_POST['bday']);
         $student->setEmail($_POST['email']);
         $student->setSex($_POST['sex']);
         $student->setAbout($_POST['message']);
         //            $studentManager->
         //            return $this->render('update');
     } else {
         return $this->render('update', ['firstname' => $studentUpdate['firstname'], 'lastname' => $studentUpdate['lastname'], 'age' => $studentUpdate['age'], 'bday' => $studentUpdate['bday'], 'email' => $studentUpdate['email'], 'sex' => $studentUpdate['sex'], 'message' => $studentUpdate['message']]);
     }
 }
示例#2
0
 public function update($id)
 {
     $conn = $this->db->getConn();
     $student = new StudentDTO();
     $sql = 'SELECT * FROM students WHERE id="' . $id . '"';
     $result = $conn->query($sql)->fetch_assoc();
     //       echo '<pre>'; print_r($result);die;
     $student->setId($result['id']);
     $student->setFirstname($result['firstname']);
     $student->setLastname($result['lastname']);
     $student->setAge($result['age']);
     $student->setBirthday($result['bday']);
     $student->setEmail($result['email']);
     $student->setSex($result['sex']);
     $student->setAbout($result['message']);
     return $result;
 }