On Fri, 14 Jun 2002, Nigel Hamilton wrote:

>       Generally I try to minimise the layers/tiers/abstraction between
> the front-end and the database - for me OO/SQL abstraction is something
> akin to 'GOTO considered harmful'.

I think there's room for middle ground here between mapping OO directly 
to SQL and having SQL in heredocs in your code.  What we tend to use is a 
object that works almost as a SQL factory.  We never have SQL directly in 
our code, but rather all this is placed inside a seperate module.that 
knows a few things about itself - e,g, what database and table we're 
using for this run.  This can be then used to spit out SQL or run the 
query and return the results.

The key aspect is that anytime you feel you need to write some SQL you 
should feel free to add more SQL to this module - not limit yourself to 
waht's already avalible.

The advantage of this is that we get better reuse in out of our SQL when
we need the same function called from many places, and we can reuse the
same SQL on similar tables/databases for different runs.  Another
advantage is that should we ever want to change the database all our SQL
is in a few modules and we can make sure that we change all our SQL.

Mark.

-- 
s''  Mark Fowler                                     London.pm   Bath.pm
     http://www.twoshortplanks.com/              [EMAIL PROTECTED]
';use Term'Cap;$t=Tgetent Term'Cap{};print$t->Tputs(cl);for$w(split/  +/
){for(0..30){$|=print$t->Tgoto(cm,$_,$y)." $w";select$k,$k,$k,.03}$y+=2}

Reply via email to