Ken, this is a great beginning. new_dbh is not a subclass though, it's a subroutine (or maybe my knowledge of the terms is off, I admit to being fairly new with packages). new_dbh is a subroutine in MyModule::Database
I can see how in the example given (thanks so much for this) where the differences are between ::db and ::st
If I setup a prepare subroutine in MyModule::Database then that would take precedence over DBI's prepare? I would just prefer than any solution not have me tracking down every $sth in our codebase and fix it (which your example helps with greatly) or having to re-code the entire MyModule::Database module to a separation of ::db and ::st
......or do I need to just setup a subclass like this...
package MyModule::Database::db;
use vars qw(@ISA);
@ISA = qw(DBI::db);
sub prepare {
my ($dbh, @args) = @_;
my $sth = $dbh->SUPER::prepare(@args)
or return;
$sth->{private_mysubdbi_info} = { foo => 'bar' };
return $sth;
}
I understand my question might not even make sense. I do enjoy this the more I learn it.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.