Look at the subclass.t test file that comes with the DBI distribution.  In
short, you'll need to inherit from all three DBI classes: DBI, DBI::db, and
DBI::st.  You'll need to use the init_rootclass() method so your constructor
returns an object of the type you created instead of a DBI::db object.

I've written a subclass which works fine.

Mitch

> -----Original Message-----
> From: Karger, Amir [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 17, 2001 8:13 AM
> To: DBI Perl mailing List (E-mail)
> Subject: inheriting from DBI::db
>
>
> I created a simple module that looks up Oracle passwords in a
> centralized
> location so that I don't have to have the password explicitly
> written in
> every piece of code I write. Now, as usual, I'm planning on
> ruining the
> module by making it much more complicated. In particular, I'm
> planning on
> caching database handles. That way, I don't have to pass
> around the handle
> to every subroutine in the program; I can just say
> &getDBH("SomeHandle") in
> each sub.
>
> In order to do this, I'm planning on inheriting from DBI::db.
> That way, I
> can set disconnect() to remove the handle from my cache, so
> that the dbh
> eventually gets DESTROYed. And do other neat things.
>
> My question is, is it safe to inherit from DBI::db? Are there
> places in the
> code that test for ref eq "DBI::db". Hopefully, they use
> isa(), but I wanted
> to make sure. Are there any other concerns I should be aware of?
>
> I thought of using connect_cached and CachedKids, but it seemed a bit
> dangerous, especially with the warnings in the docs.
>
> Amir Karger
> Curagen Corporation
>

Reply via email to