我在Doctine 2.1中有两个具有OneToOne双向关系的实体。
Foo | Bar
-------------- | --------------
id: integer | id: integer
value: integer | value: boolean
bar: Bar | foo: Foo
那样:
Foo.bar > 1...0 > Bar
我想使用Query Builder或DQL选择所有Foo记录
Foo.value > :value
或
Foo.bar
不为空,即此Bar
实体有Foo
个实体
我该怎么做?
我正在使用这样的代码:
$builder
->select('F')
->from('Foo', 'F')
->where('F.value > :value')
->orWhere('F.bar ???')
;
DQL解决方案也足够了。
答案 0 :(得分:0)
我认为 IS NOT NULL 正是您所寻找的。 p>
在DQL中:
$em->createQuery('SELECT f FROM Foo f WHERE F.value > :value OR F.bar IS NOT NULL');