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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.