Subclassing DBI - access to DBI::st attributes
From: Gordan Bobic (gordan_at_bobich.net)
Date: 02/23/05
- Next message: Martin J. Evans: "Re: [dbi] Re: Problem with DBD::ODBC (via unixODBC) connection to remote ADABAS-11 database"
- Previous message: Walter Obermiller: "Re: [dbi] Re: Problem with DBD::ODBC (via unixODBC) connection to remote ADABAS-11 database"
- Next in thread: Tim Bunce: "Re: Subclassing DBI - access to DBI::st attributes"
- Reply: Tim Bunce: "Re: Subclassing DBI - access to DBI::st attributes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 23 Feb 2005 09:23:42 +0000 To: dbi-users@perl.org
Hi,
I'm trying to subclass DBI, but I'm having problems accesing DBI::st
attributes. Say I want to override the DBI::st::execute() function to
add the ParamValues attribute contents that is missing with using the
MySQL driver.
sub execute
{
my $Self = shift;
my @Bound = @_;
my %ParamValues;
my $i;
unless ($Self->{ParamValues})
{
for $i (0 .. $#Bound)
{
$ParamValues{$i} = $Bound[$i];
print STDERR $Bound[$i] . "\n";
}
$Self->{ParamValues} = \%ParamValues;
}
return $Self -> SUPER::execute (@Bound);
}
This throws up a warning:
Can't set MyDBISubclass::st=HASH(0x818591c)->{ParamValues}: unrecognised
attribute or invalid value at .........
The ParamValues doesn't get set.
Doing something like this instead:
$Self->{foo} = "bar";
doesn't throw up a warning, but $Self->{foo} doesn't get set. Checking
it immediately after setting returns nothing.
Doing something like this:
$Self->{private_foo_} = "bar";
works, and the setting sticks, but then I cannot read it from outside
the DBI::st subclass scope.
How can I make this work?
Many thanks.
Gordan
- Next message: Martin J. Evans: "Re: [dbi] Re: Problem with DBD::ODBC (via unixODBC) connection to remote ADABAS-11 database"
- Previous message: Walter Obermiller: "Re: [dbi] Re: Problem with DBD::ODBC (via unixODBC) connection to remote ADABAS-11 database"
- Next in thread: Tim Bunce: "Re: Subclassing DBI - access to DBI::st attributes"
- Reply: Tim Bunce: "Re: Subclassing DBI - access to DBI::st attributes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]