2016-10-25 57 views
1

如何使用Doctrine查詢生成器生成嵌套查詢?Doctrine查詢生成器中的嵌套查詢

我的MySQL查詢看起來是這樣的:

SELECT subquery1.* 
FROM 
(SELECT * FROM product 
    WHERE for_her = true && age_teenagers = true && special = true) subquery1 
WHERE subquery1.song_rock =true || subquery1.describe_beauty = true; 

如何將其轉換成學說查詢在產品實體存儲庫?

回答

0

在這種情況下,查詢可能很容易重新格式化爲通常的非嵌套查詢。 據我看到它的

SELECT * FROM product 
    WHERE for_her = true AND age_teenagers = true AND special = true 
and (song_rock =true OR describe_beauty = true) 

也因此

Select P from Product P 
Where P.forHer=true AND P.ageTeenages=true AND P.specials=true and (P.songRock=true OR P.describeBeauty=true) 
+0

通過的所有記錄,這是不是真的!檢查SO q/a:http://stackoverflow.com/questions/6637506/doing-a-where-in-subquery-in-doctrine-2 –

+0

謝謝,我錯了。 –