Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^2: Passing a database connection

by aufflick (Deacon)
on Nov 23, 2005 at 00:30 UTC ( #510971=note: print w/replies, xml ) Need Help??

in reply to Re: Passing a database connection
in thread Passing a database connection

If the rest of your code uses OO mechanisms, you might want to recode new() so it will work as a class method rather than calling it as a non OO sub (ie. Main::new). The example below also checks that the passed in var is a valid DBI object. If you had done that in your code, you would have received an error as soon as you called the new method.
package Main; use strict; my $dbh; sub new { my $class = shift; my $dbh = shift; UNIVERSAL::isa($dbh, 'DBI') or die "Main->new() was invoked without a valid DBI object"; }

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-02-20 00:49 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (266 votes). Check out past polls.