0

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

4

1 に答える 1

1

さて、あなたはメソッドadd()addOrクエリビルダーを持っています:

$query = $dm->createQueryBuilder('MainClassifiedBundle:Discussion');
->add($query->field('id')->equals($discussionId))
->addOr($query->field('discussion_id')->equals($discussionId));

addまた、 andaddOrメソッドをwhereandに置き換えることもできますorWhere

于 2012-11-02T14:27:06.970 に答える