Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: object method question

by Zarathustra (Beadle)
on Oct 11, 2005 at 15:49 UTC ( [id://499203]=note: print w/replies, xml ) Need Help??


in reply to object method question

Big thanks to everyone who provided suggestions, advice - and warnings!

Special thanks to aufflick and jZed. jZed pointed out that it was DBI::db which I needed to override ( I had been working directly under DBI, which wasn't working ). aufflick showed quite succinctly how to achieve exactly what I was asking.

In my "Foo.pm" class:

{ package DBI::db; sub dbq { my $self = shift; my $sql = shift; my ( $sth ); $sth = $self->prepare( $sql ); $sth->execute; return $sth; } }

Works like a charm!

Now I can hand-off $foo->get_dbh to other classes, which are then able to $dbh->dbq( "blah" ) just as they were before -- no need for me to modify a ton of scripts and modules to subclass and/or change behavior.

Thanks again everyone,

Beers!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://499203]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-25 10:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found