Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: DBI Binding Inconsistancy

by greywolf (Priest)
on Sep 16, 2001 at 21:10 UTC ( [id://112728]=note: print w/replies, xml ) Need Help??


in reply to DBI Binding Inconsistancy

If you do not want any SQL results (empty form) you should not perform the SQL query.
if ($q->param('id')) { # perform sql query }
mr greywolf

Replies are listed 'Best First'.
(bbfu) (don't query) Re2: DBI Binding Inconsistancy
by bbfu (Curate) on Sep 16, 2001 at 22:02 UTC

    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.

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://112728]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found