sub init
{
my ($self, $config) = @_;
@$self{ keys %$config } = values %$config;
$self->{ sql } = $SQL;
$self->connect( ) || return;
return $self;
}
####
$self->init($config);
####
sub new {
my $class = shift;
# allow hash ref as first argument, otherwise fold args
# into hash
my $config = defined $_[0] &&
UNIVERSAL::isa($_[0], 'HASH')
? shift : { @_ };
no strict 'refs';
my $debug = defined $config->{ debug }
? $config->{ debug }
: defined $config->{ DEBUG }
? $config->{ DEBUG }
: ( ${"$class\::DEBUG"} || 0 );
my $self = bless {
_ID => $config->{ id } || $config->{ ID }
|| $class,
_DEBUG => $debug,
_ERROR => '',
}, $class;
return $self->init($config)
|| $class->error($self->error());
}
####
@$self{ keys %$config } = values %$config;