1

How to build nested query with Doctrine Query Builder?

My mysql query looks like this:

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;

How to convert this into Doctrine query in Product Entity Repository?

blahblah
  • 1,010
  • 15
  • 40

1 Answers1

0

In this case, the query might be easily reformated to usual not-nested query. As far as I see it's

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

And therefore

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)
Dmitry Malyshenko
  • 3,001
  • 1
  • 12
  • 20
  • By all records, that is not true! Check the SO q/a: http://stackoverflow.com/questions/6637506/doing-a-where-in-subquery-in-doctrine-2 – Jovan Perovic Oct 25 '16 at 14:11