[rt-devel] subclassing DBIx::SearchBuilder::Record
Alex Porras
alex at mediaocean.com
Tue Oct 7 11:24:37 EDT 2003
I'm trying to subclass DBIx::SearchBuilder::Record, as outlined in the
perldoc, but I seem to be having problems. I'm not sure that inheritance
is going on. I created the following file, which contains the subclass
Foo::Simple and also the code that creates a Foo::Simple object (both
parts in one perl file):
#==============================================================================
#!/usr/bin/perl
use strict;
use warnings qw(all);
use DBIx::SearchBuilder::Handle;
my $handle = DBIx::SearchBuilder::Handle->new();
$handle->Connect(
'Driver' => 'mysql',
'Database' => 'test',
'Host' => 'localhost',
'User' => '',
'Password' => ''
);
my $s = Foo::Simple->new($handle);
$s->LoadById(1);
#==============================
package Foo::Simple;
use strict;
use warnings qw(all);
use DBIx::SearchBuilder::Record;
use vars qw/@ISA/;
push(@ISA, 'DBIx::SearchBuilder::Record');
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $s = {};
bless ($s, $class);
$s->_Init(@_);
}
sub _Init {
my $s = shift;
my $handle = shift;
$s->_Handle($handle);
$s->Table("test");
return ($s);
}
sub _ClassAccessible {
return {
object_id => {'read' => 1},
object_title => {'read' => 1, 'write' => 1},
};
}
1;
#==============================================================================
When I run the script, I get the following:
Can't locate object method "_Handle" via package "Foo::Simple" (perhaps
you forgot to load "Foo::Simple"?) at ./dbixtest.pl line 45.
I saw that there is a method called "_Handle" in Record.pm, so I'm
confused as to why it's not being used.
DBIx::SearchBuilder version: 0.92
Perl version: 5.6.1
DBIx::SearchBuilder::Record version:
#$Header/cvsroot/DBIx/DBIx-SearchBuilder/SearchBuilder/Record.pm,v 1.21
2001/02/28 21:36:27 jesse Exp $
Any help would be much appreciated.
Thanks,
--Alex
More information about the Rt-devel
mailing list