in reply to Re: Leashing DBI
in thread Leashing DBI
Ah. Nice approach.
I would like to mention the possibility to use functions instead of constants, and move all these functions to a separate module.
This all in the spirit of McConnell's Code Complete. Paraphrased: If you don't like/ grog/ find strange/ consider to be difficult a certain library or structure or whatever, interface it in a separate module. That way, you don't clutter up your main code with things that are unclear and hard to maintain. As a spin-off, you can reuse that module.
In this case, you could write functions with very descriptive names just as wrappers for the SQL:
package SQL_functions; sub select_picture_from_userID{ my $userID = shift; "SELECT pict FROM users WHERE ID = $userID;" } sub select_some_nifty_case_with_contstraints{ ... #hehe, perl6 only } #and in the "main" code: use SQL_functions qw/:all/; my $sth = $dbh->prepare( select_picture_from_userID( 666 ) ) or die...
Hope this helps,
Jeroen
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re:{2} Leashing DBI
by Masem (Monsignor) on Jun 27, 2001 at 17:53 UTC | |
by pope (Friar) on Jun 28, 2001 at 03:52 UTC | |
by Masem (Monsignor) on Jun 28, 2001 at 04:00 UTC |
In Section
Meditations