I have the following query which is providing undesired results.
$query = $dm->createQueryBuilder('MainClassifiedBundle:Discussion')
->field('id')->equals($discussionId)
->field('discussion_id')->equals($discussionId);
What I am trying to do is to find any documents where id = $discussionId OR discussion_id =$discussionId.
Many thanks for your help
Well, you have the methods add()
and addOr
of query builder:
$query = $dm->createQueryBuilder('MainClassifiedBundle:Discussion');
->add($query->field('id')->equals($discussionId))
->addOr($query->field('discussion_id')->equals($discussionId));
Also you can replace the add
and methods by addOr
where
and orWhere