Skip to content
Advertisement

Top level EXISTS query using Doctrine ORM

I have a query such as this in plain SQL (of course the original is more complex, but still simple enough that I’m quite sure that that part is correct at least):

JavaScript

The question is: How do I do this using Doctrine ORM DQL?

My current state looks as follows:

JavaScript

This will throw a parsing error, as EXISTS is an unknown function (and there is no built-in function to cover this). Using a native query didn’t work either, but I might have messed this up, so am grateful for a correct example including a result set mapping.

There are answers for similar questions on SO, but I haven’t found this exact problem.

Thanks for your help!

Advertisement

Answer

OK, despite feeling a bit wrong, I solved the problem by using a native query. Here it is for reference (still open for improvement though):

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement