This is the essentials of what worked for me after
studying subclass.t:
====================================
package PDBA::CM;
require DBI;
@ISA=qw(DBI);
__PACKAGE__->init_rootclass;
use Carp;
use strict;
use warnings;
use diagnostics;
sub new {
# bunch of code goes here
}
package PDBA::CM::db;
no strict 'vars';
@ISA = qw(DBI::db);
package PDBA::CM::st;
no strict 'vars';
@ISA = qw(DBI::st);
1;
================================
May not be perfect, but it works.
Jared
On Friday 23 August 2002 15:14, John Coy wrote:
> Hi,
>
> I am trying to create a new class that inherits from
> DBI. However, I cannot seem to get it working properly:
>
> -- my new class --
> package Db;
>
> use base DBI;
> use strict;
>
> sub hello {
> my($self) = shift;
>
> return "Hello world";
> }
>
> 1;
> -- end new class --
>
> -- my test program --
> #! /usr/bin/perl
> #
> use Db;
> use strict;
>
> my $dbh = Db->connect('dbi:Oracle:', 'username', 'password');
> print $dbh->hello(), "\n";
> -- end test program --
>
> When I run the test program, I get:
>
> Can't locate object method "hello" via package "DBI::db" (perhaps you
> forgot to load "DBI::db"?) at test.pl line 7.
>
> It's clear that the $dbh object returned by Db->connect() doesn't
> belong to the Db subclass I created.
>
> As you can tell, I'm not that good with OO programming, but I'd
> like to learn.
>
> Assistance is appreciated.
>
> John
>
> ---
> John Coy
> CTO/VP Network Operations
> ANCI/Arkansas.Net