Re: OO Architecture
[email protected] ("H.Merijn Brand") Wed, 28 Sep 2005 12:47:06 +0200
| Newsgroups | perl.dbi2.dev |
|---|---|
| Message-ID | <20050928124706.4529bf12@pc09> |
On Fri, 23 Sep 2005 21:11:02 +0100, Tim Bunce <[email protected]> wrote: > > >But here's another, deeper, question that's more relevant at this point: > > >"is subclassing the DBI actually important?" I don't think that's a fair question in this *dev* list. I think most of us know how to find workarounds for things that are currently impossible or hard to do in DBI > > I do strongly believe: It is. > > Ah, you can't get away that easily! *Why* do you strongly believe it is? The easier it is to use and/or extend (and thus use) the DBI in general, the more feedback you/we get, and the better the final product will be. Curious: how much feedback/patches did you receive on the DBI API from *users* as opposed to/compared to comments/patches/feedback from DBD-authors? > What examples of DBI subclassing can you show to prove your case? I use these extension for ages: # These three provide methods that prevent NULL values in the database # Oracle translates empty VARCHAR2 values to NULL :[[[ sub DBI::st::insert ($@) { my $sth = shift; $sth->execute (map { defined ($_) && $_ eq "" ? " " : $_ } @_); } # insert sub DBI::st::update ($@) { my $sth = shift; $sth->execute (map { defined ($_) && $_ eq "" ? " " : $_ } @_); } # update sub DBI::st::getrows ($@) { my $sth = shift; my @r = (); $sth->execute (@_); while (my @f = $sth->fetchrow_array) { push @r, @f == 1 ? $f[0] : [ @f ]; } @r; } # getrows -- H.Merijn Brand Amsterdam Perl Mongers (http://amsterdam.pm.org/) using Perl 5.6.2, 5.8.0, 5.8.5, & 5.9.2 on HP-UX 10.20, 11.00 & 11.11, AIX 4.3 & 5.2, SuSE 9.2 & 9.3, and Cygwin. http://www.cmve.net/~merijn Smoking perl: http://www.test-smoke.org, perl QA: http://qa.perl.org reports to: [email protected], [email protected]