To avoid dbh beeing distroyed without disconnection from DB,
change the _init() sub like this
(oups ! Super:: should be SUPER:: I guess :)
sub _init{
my($self,@args) = @_;
ref($self) || croak "$self is not an object\n";
#let DBI to make the connection and keep the dbh as an attribute
$self->{DBH}=$self->SUPER::connect(@args);
}
Also provide a DISTROY method to your Db class in order to always disconnect before
distroying a dbh
Sub DISTROY{
my($self)=(@_);
$self->{DBH} and $self->SUPER::disconnect();
}
Jos�.
-----Original Message-----
From: John Coy [mailto:[EMAIL PROTECTED]]
Sent: Saturday, August 24, 2002 5:49 AM
To: [EMAIL PROTECTED]
Subject: Re: how to properly extend DBI class?
>You missed a lot in building package and classes.
>Look at perlmod and perlobj documentation.
I ready very carefully much of the perl-provided documentation concerning
object-oriented programming. Thanks.
>At least you will need to set @ISA to define inheritance, and @EXPORT
>to define which item are available for the user of the package.
I address this below.
>Good luck with your codes.
..... and luck to yours as well.
It's my understanding that 'use base' accomplishes
manipulating the @ISA array. If you do a 'perldoc base' you'll see what I mean --
base.pm is a bundled module with most perl distributions. I have successfully used
'use base' with my own classes to accomplish inheritance and I have been successful.
As for @EXPORT, I read very carefully 'man perltoot' and it does say that a
"well-behaved" class doesn't export. I was attempting to make a well-behaved class.
Michael A Chase <[EMAIL PROTECTED]> gave feedback concerning the syntax of 'use
base DBI' vs. 'use base qw(DBI)'. I tried it the other way but I still get the same
result.
If it helps any, I've been programming in Perl and using DBD/DBI for quite some time.
This is just my first time trying to extend the DBI class with a custom sub-class.
Any assistance is greatly appreciated.
---
John Coy
CTO/VP Network Operations
ANCI/Arkansas.Net
**** DISCLAIMER ****
"This e-mail and any attachment thereto may contain information which is confidential
and/or protected by intellectual property rights and are intended for the sole use of
the recipient(s) named above.
Any use of the information contained herein (including, but not limited to, total or
partial reproduction, communication or distribution in any form) by other persons than
the designated recipient(s) is prohibited.
If you have received this e-mail in error, please notify the sender either by
telephone or by e-mail and delete the material from any computer".
Thank you for your cooperation.
For further information about Proximus mobile phone services please see our website at
http://www.proximus.be or refer to any Proximus agent.