in reply to Re: Re: Abstracting sql
in thread Abstracting sql

I really like the idea of using data functions to map from perl to sql. Unfortunately it looks like using your examples would give me the worst of both worlds, as I would still end up with sql being strewn around in the middle of my code and I see no easy way to easily be "database agnostic" with those subs, other then just writing one set of subs for every single database I want to use.
Using these data functions you at least limit the SQL to a specific module (or set of modules), and this set of modules could quite easily be a hierarchy that takes database specificities into account.

Another possibility is to store the SQL in a separate file (text file, DB_File or something else) indexed by logical request. Load the file at startup and map perl subroutines to SQL statements.

There are always a bunch of ways to do these things... :-)

Michael

Replies are listed 'Best First'.
Re: Re: Re: Re: Abstracting sql
by BUU (Prior) on Jul 31, 2003 at 16:48 UTC
    Heh, actually on further thought, I decided that a classic OOP method would be the best solution. I could define the basic/default "data access class" with all the fun little members like get_user_data; or whatever I decide I need, then every database specific implementation can simply inherit from the default class and I can easily over ride any method that needs "custom sql", or even override the entire class entirely (say If I wanted to use flat files or something..)