I thought I pretty much understood inheritance, but I am missing something in my latest attempt. I am trying to make a simple class that inherits from DBIx::SQLEngine. I have not attempted to add any methods, just to implement a new() method in MY class that generates an object that @ISA DBIx::SQLEngine. I keep getting an error that looks like I am not actually inheriting any methods from DBIx::SQLEngine. Here is the simple module code (and made change to call to SUPER::new() directly--thanks frodo72):
And here is a little test script, debugger output, and error message:package Bio::DB::UCSC::DB; use strict; use DBIx::SQLEngine; our @ISA = qw/DBIx::SQLEngine/; sub new { my $proto = shift; my $class = $proto; my $self = $class->SUPER::new(@_); bless($self, $class); return($self); } 1;
From the debugger, I dump out the $db and $sqldb objects, which look like:#!/usr/bin/perl use strict; use Bio::DB::UCSC::DB; use DBIx::SQLEngine; my $db = Bio::DB::UCSC::DB->new('dbi:mysql:database=hg18','uname','pas +swd'); my $sqldb = DBIx::SQLEngine->new('dbi:mysql:database=hg18','uname','pa +sswd'); my $refGenes1 = $sqldb->fetch_select( tables => {'refGene.name' => 'refLink.mrnaAcc'}, where => ['refGene.name like ?','NM_0002%']); my $refGenes = $db->fetch_select( tables => {'refGene.name' => 'refLink.mrnaAcc'}, where => ['refGene.name like ?','NM_0002%']);
So, they look OK, but I get an error when I try to use the $db object:DB<3> x $sqldb 0 DBIx::SQLEngine::Driver::Mysql::V3_0=HASH(0x1a7c478) 'dbh' => DBI::db=HASH(0x1a28f78) empty hash 'package' => 'DBIx::SQLEngine::Driver' 'reconnector' => CODE(0x1a7c4a8) -> &DBIx::SQLEngine::Driver::__ANON__[/Library/Perl/5.8.1/DBIx/S +QLEngine/Driver.pm:252] in /Library/Perl/5.8.1/DBIx/SQLEngine/Driver. +pm:252-252 DB<4> x $db 0 Bio::DB::UCSC::DB=HASH(0x1a28f54) 'dbh' => DBI::db=HASH(0x15c1fb8) empty hash 'package' => 'DBIx::SQLEngine::Driver' 'reconnector' => CODE(0x1a29938) -> &DBIx::SQLEngine::Driver::__ANON__[/Library/Perl/5.8.1/DBIx/S +QLEngine/Driver.pm:252] in /Library/Perl/5.8.1/DBIx/SQLEngine/Driver. +pm:252-252
main::(test.pl:16): my $refGenes = $db->fetch_select(tables => {'r +efGene.name' => 'refLink.mrnaAcc'}, main::(test.pl:17): where => ['re +fGene.name like ?','NM_0002%']); DB<1> Can't locate object method "fetch_select" via package "Bio::DB::UCSC:: +DB" at test.pl line 16. at test.pl line 16 Debugged program terminated. Use q to quit or R to restart,
Any hints are appreciated.
Thanks,
Sean
In reply to Inheritance confusion by srdst13
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |