Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. protected function buildDomainObject(array $row)
  2. {
  3. $reply = new Reply();
  4. $reply->setId($row['reply_id']);
  5. $reply->setAuthor($row['reply_author']);
  6. $reply->setContent($row['reply_content']);
  7. $reply->setComParent($row['com_id']);
  8. $reply->setLevel($row['reply_level']);
  9.  
  10. if (array_key_exists('art_id', $row))
  11. {
  12. $commentaireId = $row['art_id'];
  13. $article = $this->articleDAO->find($commentaireId);
  14. $reply->setArticle($article);
  15. }
  16. return $reply;
  17. }
  18.  
  19. public function save(Reply $reply) {
  20.  
  21. $commentData = array(
  22. 'reply_content' => $reply->getContent(),
  23. 'reply_author' => $reply->getAuthor(),
  24. 'com_id' => $reply->getComParent(),
  25. 'art_id' => $reply->getArticle()->getId(),
  26. 'reply_level' => $reply->getLevel()
  27. );
  28.  
  29. if ($reply->getId()) {
  30. // update comment
  31. $this->getDb()->update('t_reply', $commentData, array('reply_id' => $reply->getId()));
  32. } else {
  33. // The comment has never been saved : insert it
  34. $this->getDb()->insert('t_reply', $commentData);
  35. // Get the id of the newly created comment and set it on the entity.
  36. $id = $this->getDb()->lastInsertId();
  37. $reply->setId($id);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement