Newscoop\Services\CommentService::searchByPhrase PHP Method

searchByPhrase() public method

Searchs comments by given phrase
public searchByPhrase ( string $phrase ) : Doctrine\ORM\QueryBuilder
$phrase string Phrase
return Doctrine\ORM\QueryBuilder
    public function searchByPhrase($phrase)
    {
        $queryBuilder = $this->em->getRepository('Newscoop\\Entity\\Comment')->createQueryBuilder('c');
        $queryBuilder->select('c', 'cm.name')->leftJoin('c.commenter', 'cm')->leftJoin('Newscoop\\Entity\\Article', 't', Expr\Join::WITH, 'c.thread = t.number AND c.language = t.language')->where($queryBuilder->expr()->orX($queryBuilder->expr()->like('c.message', $queryBuilder->expr()->literal('%' . $phrase . '%')), $queryBuilder->expr()->like('c.subject', $queryBuilder->expr()->literal('%' . $phrase . '%')), $queryBuilder->expr()->like('cm.name', $queryBuilder->expr()->literal('%' . $phrase . '%')), $queryBuilder->expr()->like('cm.email', $queryBuilder->expr()->literal('%' . $phrase . '%')), $queryBuilder->expr()->like('t.name', $queryBuilder->expr()->literal('%' . $phrase . '%'))))->andWhere('c.status != 3')->orderBy('c.time_created', 'desc');
        return $queryBuilder;
    }