Пример #1
0
 /**
  * updates a Comment data row
  *
  * @param IComment $comment
  * @return bool
  * @throws NotFoundException
  */
 protected function update(IComment $comment)
 {
     $qb = $this->dbConn->getQueryBuilder();
     $affectedRows = $qb->update('comments')->set('parent_id', $qb->createNamedParameter($comment->getParentId()))->set('topmost_parent_id', $qb->createNamedParameter($comment->getTopmostParentId()))->set('children_count', $qb->createNamedParameter($comment->getChildrenCount()))->set('actor_type', $qb->createNamedParameter($comment->getActorType()))->set('actor_id', $qb->createNamedParameter($comment->getActorId()))->set('message', $qb->createNamedParameter($comment->getMessage()))->set('verb', $qb->createNamedParameter($comment->getVerb()))->set('creation_timestamp', $qb->createNamedParameter($comment->getCreationDateTime(), 'datetime'))->set('latest_child_timestamp', $qb->createNamedParameter($comment->getLatestChildDateTime(), 'datetime'))->set('object_type', $qb->createNamedParameter($comment->getObjectType()))->set('object_id', $qb->createNamedParameter($comment->getObjectId()))->where($qb->expr()->eq('id', $qb->createParameter('id')))->setParameter('id', $comment->getId())->execute();
     if ($affectedRows === 0) {
         throw new NotFoundException('Comment to update does ceased to exist');
     }
     $this->dispatcher->dispatch(CommentsEvent::EVENT_UPDATE, new CommentsEvent(CommentsEvent::EVENT_UPDATE, $comment));
     return $affectedRows > 0;
 }