debiandude has asked for the wisdom of the Perl Monks concerning the following question:

I previously wrote a wrapper module for Sybase::DBlib. I had made some nice convenience functions for myself that made writing DB programs very easy. Howerver, I am converting all my stuff to an ODBC databaes now and rewiting all my programs would take a lot of work.

Since I wrote this library that is used by everything, I would like to just replace that library (by providing the same functionlity just using DBI) and not have to touch any of the files. However, I cannot seem to figure out how to inhert from dbi. Can anyone give me any clues?

Replies are listed 'Best First'.
Re: Inheriting from DBI
by dragonchild (Archbishop) on Jan 11, 2005 at 19:04 UTC
    Don't inherit. Create a wrapper that HAS-A DBI object and makes calls on it. Inheritance is for when you plan on offering the same API with a few changes. Delegation (which is what you're doing) is for when you want to provide a completely different API.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re: Inheriting from DBI
by dbwiz (Curate) on Jan 11, 2005 at 19:38 UTC

    I second dragonchild's advice. A wrapper is better.

    However, if you really must, you may take as an example DBIx::HA, which is inherited from DBI. At least, you may see how it is done.

    Check the source code