Esempio n. 1
0
 public function getCommentsAfter(Message $message, Comment $comment = null, $direction = 0)
 {
     $crt = array('message' => $message);
     $qb = $this->createQueryBuilder('c')->select()->where('c.message = :message');
     //direction false is down / true is up
     if (!(bool) $direction) {
         if ($comment !== null) {
             $qb->andWhere('c.id < :cid');
             $crt['cid'] = $comment->getId();
         }
     } else {
         if ($comment !== null) {
             $qb->andWhere('c.id > :cid');
             $crt['cid'] = $comment->getId();
         }
     }
     $qb->setParameters($crt);
     $qb->addOrderBy('c.id', 'DESC');
     $query = $qb->getQuery();
     $query->setMaxResults(Comment::MAX_RESULTS);
     return $query->getResult();
 }