there is my problem :
return $this->createQueryBuilder('p') ->select('p as post') ->where(':tags MEMBER OF p.tags') ->setParameter('tags', array_values($tagArray)) ->orderBy('p.postedAt', 'DESC') ->setFirstResult($start) ->setMaxResults($limit) ->getQuery() ->getResult() ;
With this code, I can retrieve all posts that have as tags those present in $tagArray.
But for example if we have this dataset:
post1 with tag1, tag2 and tag3
post 2 with tag1, tag3, tag4
Currently if I search with tag1, tag2 I will get this result:
post1 and post2.
How can I get only post1? MEMBER OF seems to make the condition sound like tag1 OR tag2, would there be a way to do a tag1 AND tag2 ?
Thank you for your answers
Source: Symfony Questions
Was this helpful?
0 / 0