public function addComments() { $post = $this->em->find('models\Post','1'); $user = $this->em->find('models\User','2'); $user2 = $this->em->find('models\User','3'); $comment = new models\Comment; $comment->setPost($post); $comment->setUser($user); $comment->setContent("Ugly article ...."); $this->em->persist($comment); $comment = new models\Comment; $comment->setPost($post); $comment->setUser($user2); $comment->setContent("I agree ...."); $this->em->persist($comment); $this->em->flush(); $data['message'] = 'done'; $this->load->view('home', $data); }
public function comment($id) { if ($this->_submit_comment_validate() === FALSE) { $this->show($id); return; } $post = $this->em->find('models\Post', $id); $user = models\Current_User::user(); $content = $this->input->post('comment'); if ($post && $user && $post->getFlag()!='deleted') { $comment = new models\Comment; $comment->setUser($user); $comment->setPost($post); $comment->setContent($content); $this->em->persist($comment); $this->em->flush(); $this->show($id); } }