From ee122a7528f55dfb5f02e351c509d00b756fedaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 4 Nov 2016 23:24:43 +0100 Subject: Added a simple search engine Fix #18 --- .../CoreBundle/Repository/EntryRepository.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/Wallabag/CoreBundle/Repository') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 61be5220..8f23164f 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -85,6 +85,25 @@ class EntryRepository extends EntityRepository ; } + /** + * Retrieves entries filtered with a search term for a user. + * + * @param int $userId + * @param string $term + * + * @return QueryBuilder + */ + public function getBuilderForSearchByUser($userId, $term) + { + return $this + ->getBuilderByUser($userId) + ->andWhere('e.content LIKE :term')->setParameter('term', '%'.$term.'%') + ->orWhere('e.title LIKE :term')->setParameter('term', '%'.$term.'%') + ->leftJoin('e.tags', 't') + ->groupBy('e.id') + ->having('count(t.id) = 0'); + } + /** * Retrieves untagged entries for a user. * -- cgit v1.2.3