%% Steve Sapovits <[EMAIL PROTECTED]> writes:

  ss> It's not that hard.  I subclassed it for the purpose of allowing
  ss> logical database names that we map to the real DBI resource 
  ss> strings.  Among other things, that gives us one place to change
  ss> where a given database/schema really is.  I'm attaching that 
  ss> code so you can see what you have to do to subclass DBI.

This was very helpful, thanks!

I got it working.

There is one issue left:

When I try to use $sth->errstr, for example, from within my classes, I
get a reference error.

My code looks like this now:

  package MyDB::DB::db;
  use vars qw(@ISA);
  @ISA = qw(DBI::db);

  sub MySend {
    my $this = shift;

    my $sth = $this->SUPER::prepare("@_")
      or croak "DB Error: $this->errstr\n";

    $sth->execute()
      or croak "DB Error: $sth->errstr\n";

    return ($sth);
  }

I haven't had the first one fail yet (I'm using mysql so I don't think
the prepare statement does very much), but if I get an error from the
second one the output says:

  DB Error: MyDB::DB::st=HASH(0x82e78a0)->errstr
     at ...

rather than printing the actual error string.

I also tried something weird like $sth->SUPER::errstr, but that didn't
work any better :).

Is errstr a class variable, rather than a method?  Can I "inherit" that
as well?

Not a huge deal, I guess, but still...

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>    HASMAT--HA Software Methods & Tools
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.

Reply via email to