Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: A more elegant solution?

by htoug (Deacon)
on Aug 19, 2001 at 19:10 UTC ( #106027=note: print w/ replies, xml ) Need Help??


in reply to Re: A more elegant solution?
in thread A more elegant solution?

Why use prepare_cached?

It is mainly of use when you have a few statements, that you execute often, but where you are unable to hold a reference to the $sth.

And it is only usefull if the driver supports it. (Not all drivers do presently).

You should also note that for some databases prepared statements and placeholders take more time than just $dbh->do'ing the statement with values in place.

With those databases the only advantage of placeholders is that you don't have to do quoting - which is a big advantage in this situation, as we don't beforehand know the type of the columns, whether numeric or string. And yes that does make a big difference - some databases refuse to accept numbers in quotes as numbers!


Comment on Re: Re: A more elegant solution?
Re: Re: Re: A more elegant solution?
by runrig (Abbot) on Aug 20, 2001 at 02:27 UTC
    Why use prepare_cached?

    It is mainly of use when you have a few statements, that you execute often, but where you are unable to hold a reference to the $sth. I've never yet been unable to hold a reference, you can store them in package variables or closures. I'd say its more for when its inconvienient to store the handle, so you lazily decide to let DBI do it for you :)

    And I've seen this happen occasionally when people have hashes of column names and values which is when this solution is usually ideal.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2014-04-21 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (490 votes), past polls