Joe Breeden [mailto:[EMAIL PROTECTED]] wrote:
...
> wondering about alternatives to embedding SQL in to the code 
> of a program.
...
> It would be interesting to know how other people have solved 
> that problem.

One approach is to use something like Ima::DBI, which I'm currently toying
with.  With Ima::DBI, you still embed your SQL in your perl code, but at
least you put all of your SQL into a single module somewhere and you do so
in a very structured way.  

To access the database from the rest of your program, you call methods of
your database query object.  This is a lot cleaner than whipping up a query
string every time you want to hit the database.  It's also a lot more
flexible.  You could, for instance, create different database classes for
different database backends, and still keep the programming interface the
same.

Of course you could do all this without Ima::DBI; roll up your own custom
database wrapper classes.  But Ima::DBI also handles some mod_perl DBI
issues such as guaranteeing one DBI statement handle per process.  


Michael

Reply via email to