[eluser]jedd[/eluser]
Ahh .. speculative coding. My favourite type.
I'd have a directory that the files were loaded into - called something imaginative like ./avatars/
The avatar file upload process would do the vetting (including staging by moderators if you want) and rename the file to the user-id.png (I'd convert to a consistent format on the way in - not a huge fan of jpeg).
I'd have a model function that would return the avatar for a given user, and that would be a link to an image file - if the user existed it'd point to the user_id.png file, otherwise it'd point to default.png - or some similar logic. The avatar-lookup method would *always* return a pointer to an image file, mind.
I'm a big fan of not storing image blobs within database tables too, btw.
But I'm not quite sure what the actual problem is - the original question seems to pose a fairly straightforward problem of identifying if a record in a table exists, and then acting differently based on the results of that lookup. I feel I'm missing something.