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