Inheritance confusion

[prev] [thread] [next] [Date index for 2005/02/20]

From: Warren Pollans
Subject: Inheritance confusion
Date: 04:05 on 20 Feb 2005
Hello,

I'm trying to write a sub in my main Class::DBI class that's to be 
inherited by subclasses.  I've run into a problem that I can't figure 
out.  My parent class and a test script that failed are listed below.  
I've created a set_sql() called tableinfo.  sql_tableinfo is inherited 
by subclasses - i.e., <subclass>->sql_tableinfo works OK.  However, 
when I try to use <subclass>->search_tableinfo, there is a complaint: 
Can't locate object method "search_tableinfo" via package in the 
<subclass>

There's something very basic that I've missed.  Help please.

Thanks,

Warren

+++++[  test script  ]++++++++
#!/opt/bin/perl -w
use strict;
use DanceDB::DBI::Dances;

my($fields, $props) = DanceDB::DBI::Dances->get_tableinfo();

print "F: $fields\n";
print "P: $props\n";

+++++[  main class  ]++++++++++
package DanceDB::DBI::DBI;
use base "Class::DBI::mysql";

__PACKAGE__->set_db('Main', 'dbi:mysql:dance_test', 'test_user', 
'testpass');
__PACKAGE__->set_sql(tableinfo => qq| show columns from __TABLE__ |);

sub get_tableinfo {

     my $class = shift;
     my(@fields, %properties);

     my @rows = $class->search_tableinfo();
     foreach my $row (@rows) {

         $properties{$row->Field} = $row;

         push(@fields, $row->Field);

     }

     return(\@fields, \%properties);
}

1;
++++++++++++++

Inheritance confusion
Warren Pollans 04:05 on 20 Feb 2005

Re: Inheritance confusion
Tony Bowden 09:41 on 20 Feb 2005

Generated at 11:30 on 23 Feb 2005 by mariachi v0.52