blahblah blahblah - 9 months ago 74
MySQL Question

Nested query in Doctrine query builder

How to build nested query with Doctrine Query Builder?

My mysql query looks like this:

SELECT subquery1.*
(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?

Answer Source

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)