Skip to content
Advertisement

Doctrine QueryBuilder – CASE WHEN

I have a question about case when in doctrine. The problem with this is when uim.isProfileImage is 1 for a user, that returns that row and every other row in user_image table for that user. What I want is, if there is a profile image (isProfileImage is 1 in user_image table, there can be only one row with that value for same user) give me only that row, and if there isn’t something like that give me null for that.

JavaScript

So it should look something like this: With profile image:

JavaScript

And without profile image:

JavaScript

Also since there is an in expr, it should work with multiple ids that pass to this function. Thanks in advance.

Advertisement

Answer

Try this:

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