A bit of advice for you. I have been told this a couple
of times myself at this site.;)
Checking $DBI::errstr is best done when instantiating a
DBI::db object, since you will not have a reference to
the object if the connect fails. After the instantiation,
say to the var $dbh, you should check the err() method
or the more useful errstr()
method: or die $dbh->errstr(). But....
An even lazier solution is to force errors to raise
exceptions via the RaiseError attribute. You do so by
passing a hash ref to the constructor like so:
my $dbh = DB->connect(
'DBI:vendor:database:host','user','pass',
{ RaiseError => 1},
);
Now you don't have to 'or die' after every query (method
call).
Setting 'PrintError' to false is useful in conjunction
with 'RaiseError' set to true when you use eval to catch exceptions, rather than die on them. Doing so supresses
the 'error messages' that are generated when DBI calls
die.
just tryin to be helpful ;)
jeffa
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)
|