Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected function buildDomainObject(array $row)
- {
- $reply = new Reply();
- $reply->setId($row['reply_id']);
- $reply->setAuthor($row['reply_author']);
- $reply->setContent($row['reply_content']);
- $reply->setComParent($row['com_id']);
- $reply->setLevel($row['reply_level']);
- if (array_key_exists('art_id', $row))
- {
- $commentaireId = $row['art_id'];
- $article = $this->articleDAO->find($commentaireId);
- $reply->setArticle($article);
- }
- return $reply;
- }
- public function save(Reply $reply) {
- $commentData = array(
- 'reply_content' => $reply->getContent(),
- 'reply_author' => $reply->getAuthor(),
- 'com_id' => $reply->getComParent(),
- 'art_id' => $reply->getArticle()->getId(),
- 'reply_level' => $reply->getLevel()
- );
- if ($reply->getId()) {
- // update comment
- $this->getDb()->update('t_reply', $commentData, array('reply_id' => $reply->getId()));
- } else {
- // The comment has never been saved : insert it
- $this->getDb()->insert('t_reply', $commentData);
- // Get the id of the newly created comment and set it on the entity.
- $id = $this->getDb()->lastInsertId();
- $reply->setId($id);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement