On Mon, Mar 29, 2004 at 12:21:05PM +0100, Tim Bunce wrote:
> On Sun, Mar 28, 2004 at 01:56:05PM -0800, Dean Arnold wrote:
> > Have the DBI->err(), DBI->errstr(), DBI->state() been
> > deprecated ? I see the err() and errstr() are still
> > in the DBI.pm code, but no trace of state() (as far
> > back as 1.38)
> >
> > FYI: I'm trying to check state info on a connection
> > failure, so I don't have a "handle" to call state() on.
> >
> > Or is the preferred solution to read the $DBI::state
> > variable directly ?
>
> Yes. DBI->err() and DBI->errstr() were never in the spec
> and they'll be removed in DBI v2.
Okay, there seems to be some confusion here.
Ultimately the only access to a handle's err, errstr, and state are
through method calls on the *handle* (the object reference):
$h->err
$h->errstr
$h->state
As a convienience the DBI also provides these *tied* variables
$DBI::err
$DBI::errstr
$DBI::state
when you access $DBI::err, for example, the FETCH method of
the tied variable is called and that calls the err() method
on the last handle the DBI used.
So, having recapped on the background information...
This thread is discussing the undocumented *static* (class) methods
DBI->err
DBI->errstr
which are simply defined as
package DBI;
sub err { $DBI::err }
sub errstr { $DBI::errstr }
No one should be using them. They were never documented.
Where the documentation refers to $h->err the $h means a *handle*.
The DBI in DBI->err is not a handle, it's a class name.
For DBI v2 I'll probably leave them but make them issue a warning.
You have been warned :)
Tim.