Esempio n. 1
0
 public function save(Comment $comment)
 {
     $commentData = array('art_id' => $comment->getArticle()->getId(), 'user_id' => $comment->getAuthor()->getId(), 'com_content' => $comment->getContent());
     if ($comment->getId()) {
         // The comment has already been saved : update it
         $this->getDb()->update('comment', $commentData, array('com_id' => $comment->getId()));
     } else {
         // The comment has never been saved : insert it
         $this->getDb()->insert('comment', $commentData);
         // Get the id of the newly created comment and set it on the entity.
         $id = $this->getDb()->lastInsertId();
         $comment->setId($id);
     }
 }