in reply to Re: DBI-disconnect ???
in thread DBI-disconnect ???

Aha! This looks like a similar problem to my own... I'm a relative beginner when it comes to inheritance, so I'm sure that's where my problem lies. Here's what I'm doing: I have a class, "class_X", which is a subclass of DBI, and another class, "class_Y", which is a subclass of class_X. class_X is fairly generic, and merely extends some of the DBI functionality; class_Y is more specific to my database needs. Here's some relevant code:
package class_X; require DBI; @ISA = qw( DBI ); sub new { my( $class, $dns, $username, $password ) = @_; my %attr = ( PrintError => 1, RaiseError => 0, AutoCommit => 1 ); my $self = DBI->connect( $dns, $username, $password, \%attr ) or +return; push @ISA, ref $self if( not grep { $_ eq ref $self } @ISA ); return bless $self, $class; } sub DESTROY { my( $self ) = @_; $self->disconnect; } 1; package class_Y; require class_X; @ISA = qw( class_X ); sub new { my( $class ) = @_; my $dns = "DBI:mysql:database=XXX"; my $user = "XXX"; my $pwd = "XXX"; my $self = class_X->new( $dns, $user, $pwd ); return bless $self, $class; } sub DESTROY { my( $self ) = @_; $self->disconnect; } 1;

This used to work fine (before upgrading DBI); now I'm having the same problem as mentioned in the links you (so graciously) forwarded.

I haven't yet been able to wrap my brain around the problem and figure out exactly how to solve it... Any friendly nudges in the right direction?

Replies are listed 'Best First'.
Re: Re: Re: DBI-disconnect ???
by mattr (Curate) on Aug 14, 2001 at 16:28 UTC
    Okay, here is my off-the-cuff guess.

    Why not change package class_Y from
    @ISA = qw( class_X );
    to
    @ISA = qw( DBI class_X );

      If I do that, then none of my class_Y methods are available -- it looks in DBI, fails to find them (in DBI::db), and croaks.