Пример #1
0
 public function processAction()
 {
     if (isset($_POST['programName'], $_POST['duration'], $_POST['directorId'])) {
         $_POST['directorId'] = (int) $_POST['directorId'];
         $_POST['programName'] = strip_tags($_POST['programName']);
         $_POST['duration'] = strip_tags($_POST['duration']);
         $dto = new ProgramDTO();
         $dao = new ProgramDAO();
         $dto->hydrate($_POST);
         // id = -1 if you come from the insert form
         if (-1 == $_POST['id']) {
             $dao->insert($dto);
         } else {
             $dao->update($dto);
         }
     }
     header('Location: index.php?ctrl=program&act=indexProg');
 }
Пример #2
0
 public function update(ProgramDTO $prog)
 {
     // if id = -1, there is nothing to do
     if (-1 === $prog->getProgramId()) {
         return;
     }
     $stmt = $this->pdo->prepare("UPDATE programme SET nom_programme = ?, duree = ?, realisateur_id = ?,type_id = ? WHERE programme_id = ?;");
     $stmt->bindValue(1, $prog->getProgramName());
     $stmt->bindValue(2, $prog->getDuration());
     $stmt->bindValue(3, $prog->getDirectorId());
     $stmt->bindValue(4, $prog->getTypeId());
     $stmt->bindValue(5, $prog->getProgramId());
     $stmt->execute();
 }