DBI and my laziness

jdavidb on 2006-06-21T17:34:13

I often find myself memoizing a routine that takes a DBI database handle and some SQL and returns a statement handle. I know the right way to do this is to just get the statement handle once and store it somewhere. The preferred storage spot would be in an object, but I'm not coding that way. Second best would be in a variable private to the block that needs the statement handle, but I'm too lazy even for that. I don't want to worry about where it's stored, and so I let Memoize.pm worry about it for me.

It'd be nice if DBI had a cached_prepare method to do this.

I recognize that this is not a good kind of laziness on my part. (Although I'm willing to here arguments that it is. :) )


prepare_cached is the name

rhesa on 2006-06-21T19:18:18

and it's been around since version, oh, 0.92 :)

See Changes_in_DBI_0.92.

Re:prepare_cached is the name

jdavidb on 2006-06-21T22:13:16

Thank you! I figured it was likely someone would tell me this already existed. :)