Using DBI methods

Bradley Baetz bbaetz at
Mon Aug 19 22:26:22 UTC 2002

On Mon, 19 Aug 2002, Gervase Markham wrote:

> > 1) Can use stuff like:
> >   my ($a, $b) = $dbh->selectrow_array("SELECT a,b FROM foo WHERE 
> >                                        prim_key=7");
> I'm not convinced - I find the abstraction we have, with its one 
> standard method of doing things, easy to understand and very readable. 
> The syntax above is ugly :-)

Well, its different. We can also do stuff like have C code read the values 
into a hash key;'d off some value, rather than a separate loop in the perl

> > 2) We get to use DBI's error handling + exceptions - currently we only 
> > check for errors in one place, which is bad.
> Why? I'd say it was good - I'd much rather the error handling was 
> localised than scattered throughout the code next to every database access.

It may be localised, but its wrong, because we aren't testing all teh
funtions - we should be using exceptions (via RaisError), and the DBI
HandleError attribute. Since a database error is always fatal for us,
HandleError can just truncate the message + die.

> > 4) No more state stack
> >   - don't have to worry about forgetting to push/pop the state stack -
> > simply get a new statement handle when you need one from teh globally 
> > available dbh when needed.
> This is hardly a burden - usually, it's really obvious when you've 
> forgotten.

Well, not necessarily.

> I've always thought our simple DB API was one of the good things about 
> Bugzilla's code :-)

It simple, but it doesn't allow us to use as much


More information about the developers mailing list