Business Logic inside a Query
My website allows a Member to upload one Photo to his/her Profile, however I want to Approve/Decline each uploaded file before it appears.
When I display a Member's Photo on a page, I usually am grabbing other Member Details (e.g. Username, First Name, Location, Gender, etc) from the database. And since I am trying to avoid having to call a PHP Function - with another SELECT query inside of it - to grab the "member_photo" and determine whether it was approved or not, I am wondering if I can handle all of this logic in one query?
The logic of what I need to do is pretty simple...
For a given "member.id",
if "photo_approved" = TRUE
then return "photo_name"
else return "photo_pending_approval.jpg"
Is it okay to stick that "business logic" into my MySQL Query, or should I leave that to a PHP Function??