Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^2: Inheriting from DBI

by janDD (Acolyte)
on Mar 02, 2011 at 18:50 UTC ( #891068=note: print w/replies, xml ) Need Help??

in reply to Re: Inheriting from DBI
in thread Inheriting from DBI

Well, the reason I am trying to do that is because I have to connect often to a database which is not very reliable in the sense that only one our of five connections is successful. So I want to enhance the connect, prepare, ... statements with some errorhandling (trying to reconnect several times, writing an error message by mails etc..) I am doing this now with simple functions, but I thought, a class is more appropriate ... J.

Replies are listed 'Best First'.
Re^3: Inheriting from DBI
by jeffa (Bishop) on Mar 02, 2011 at 19:07 UTC
Re^3: Inheriting from DBI
by runrig (Abbot) on Mar 03, 2011 at 15:52 UTC
    Your class doesn't need to inherit from DBI, it just needs to return a database handle. I've written lots of wrappers that connect to some default database in some default way that goes something like:
    package MyDBI; use DBI; sub connect { ...get args my $dbh; stuff $dbh = DBI->connect(...); more stuff return $dbh; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://891068]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2018-06-20 19:27 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.