On Wed, 2006-11-15 at 21:51 -0500, Chris Beck wrote:
> They say Dan Horne, on or about 15.Nov.2006 20:44, whispered:
> >> 2) (assuming the answer to 1) is here) - How do I get the error message if
> >> dbh_config fails?
> >
> > I don't think that you'll get a message. Plugin-DBH is lazy loading, so
> > the database connection won't actually get created until you try to
> > access it the first time. dbh_config just defines up the parameters for
> > the handle when it is finally used.
> >
> > To get any error message you'll need to test the $self->dbh calls (per
> > statement, using RaiseError for mutiple db calls in an eval, or perhaps
> > using something like Exception::Class::DBI)
>
> If I don't want lazy-loading should I just create my own DBH? (I want to die
> as
> soon as possible if the DB connection isn't working)
>
> Or should I do something along the lines of:
>
> $self->dbh_config($dsn,$user,$pass,{RaiseError => 1});
> eval { $self->dbh(); }
> if ($@) {
> _do_dead_db($@);
> }
>
My guess is this case is that the plugin isn't giving you any value, and
you may as well create the handle yourself in the init phase:
my $dbh = DBI->connect($dsn,$user,$pass) || _do_db_dead(DBI:errstr);
$self->param('dbh', $dbh);
and then when you need the database handle in your run modes
my $dbh = $self->param('dbh');
.. carry on coding...
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]