I have to agree with greywolf. IMO, it is conceptionally clearer (and, thus, easier to maintain) to explicitly conditionalize the execution of the query on whether or not you actually want a result (ie, have an id). It also saves load on the DB, which might not be an issue now but most likely will be at some point in the future.
bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are.
| [reply] [d/l] |
Normally I'd agree with you both but an empty set != nothing returned. In this case I need information the statement handle returns regardless of the fact there's nothing in the set.
As far as DB hit it's a precached query only using the primary key's index and I can quite confidently say that DB load isn't and won't be that much of an issue for this application. And I really mean it! Just like computers will never need more than 640k of RAM. Oohh... wait a sec. ;)
Seriously though, thanks for the suggestions. The small snippet didn't provide enough information to know otherwise.
| [reply] |