I have this really long query, which in my opinion looks ugly next to all the tidy code in my project. I was wondering if there was a way to optimize it or make it shorter at least:
$ query = <<<SQL SELECT * FROM users WHERE NOT EXISTS ( SELECT id FROM profile_likes WHERE profile_id = users.id AND viewer_id = $ my_user->id ) AND NOT EXISTS ( SELECT id FROM profile_dislikes WHERE profile_id = users.id AND viewer_id = $ my_user->id ) AND id != $ my_user->id SQL
This query is a part of an user filter which has the purpose of filtering the users to only those that the currently logged in user ($ my_user
) hasn’t liked/disliked yet.