コード例 #1
0
 protected function modify(Comment $comment)
 {
     $q = $this->dao->prepare('UPDATE comments SET autor = :autor, content = :content WHERE id = :id');
     $q->bindValue(':autor', $comment->autor());
     $q->bindValue(':content', $comment->content());
     $q->bindValue(':id', $comment->id(), \PDO::PARAM_INT);
     $q->execute();
 }
コード例 #2
0
ファイル: CommentsManager.php プロジェクト: DamdamD/Website
 /**
  * Méthode permettant d'enregistrer un commentaire.
  * @param $comment Le commentaire à enregistrer
  * @return void
  */
 public function save(Comment $comment)
 {
     if ($comment->isValid()) {
         if ($comment->isNew()) {
             $this->add($comment);
         } else {
             $this->modify($comment);
         }
     } else {
         throw new \RuntimeException('Le commentaire doit être validé pour être enregistré');
     }
 }
コード例 #3
0
 public function executeSave(HTTPRequest $request)
 {
     if ($this->user()->authLevel() <= 1) {
         echo 'false';
         exit;
     }
     $comment = new Comment();
     $comment->setContent($request->postData('content'));
     $comment->setAutor($this->user()->nickName());
     $comment->setNews($request->postData('news'));
     $manager = $this->getManagerOf($this->module, 'Comments');
     $id = $manager->save($comment);
     echo 'true';
     exit;
 }