Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Code factory

by matsmats (Monk)
on Jul 08, 2003 at 12:28 UTC ( #272252=note: print w/replies, xml ) Need Help??


in reply to Code factory

Try DBIx::SQLEngine. It's a high level interface to SQL in the same vain as some of the suggestions you have gotten here. And its quite wonderful to use if it suits your program.

It works typically like this:

$sqldb->do_insert( table => 'students', values => { 'name'=>'Dave', 'age'=>'19', 'status'=>'minor' } ); $hashes = $sqldb->fetch_select( table => 'students', criteria => { 'status'=>'minor' } );

If your project is large and might be running for a while, you should wrap all the different calls to the database in separate functions even if you've got a nice generalized interface. You will eventually have to make some workarounds or sanity checking on the data before using them, and it's thankful to have that located one place.

Mats

Replies are listed 'Best First'.
Re: Re: Code factory
by Notromda (Pilgrim) on Jul 08, 2003 at 14:13 UTC
    If your project is large and might be running for a while, you should wrap all the different calls to the database in separate functions even if you've got a nice generalized interface. You will eventually have to make some workarounds or sanity checking on the data before using them, and it's thankful to have that located one place.

    I think this is why I'm leaning toward having the many function names, even if using the factored function for the basic inserts, as tadman or flounder99 suggested. This is a mod_perl application, so there's got to be some good data checks somewhere.

    I also don't like the look of a bunch of calls like:

    getByFieldval("sometable", "somecolumn",$value1);
    all over the place. I have trouble remembering the table names and column names... Shouldn't various layers of the application be somewhat insulated from one another? Data encapsulation and all that... :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://272252]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-06-23 15:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (125 votes). Check out past polls.

    Notices?