in reply to Code factory
First thing I see wrong is the use of SELECT *. Don't do that. It's slow. It hurts maintainability. It was meant for interactive use, and has no buisness being in a program.
As for your actual question, I see two ways of doing this. Either create a closure and insert it into the main:: package space (or your current package, as the case may be), or create a subroutine which takes in SQL and a list of params for $sth->execute() and have it return the hashref. The closure version is a bit more advanced, but I suspect it will be more efficent. An example of using closures for this is in the Camel on pages 338-339.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Code factory
by tadman (Prior) on Jul 07, 2003 at 18:15 UTC | |
by perrin (Chancellor) on Jul 07, 2003 at 20:06 UTC | |
by graff (Chancellor) on Jul 08, 2003 at 04:38 UTC | |
by Notromda (Pilgrim) on Jul 08, 2003 at 14:39 UTC | |
Re: Re: Code factory
by Anonymous Monk on Jul 08, 2003 at 18:28 UTC |