Re: [CDBI] Ima::DBI and mod_perl2

Perrin Harkins <[email protected]> Wed, 3 Nov 2010 15:35:57 -0400
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
On Wed, Nov 3, 2010 at 12:28 PM, Michele Valzelli
<[email protected]> wrote:
> Just putting
> the=A0Your_CDBI::Class->db_Main->do($sql_statement); line after the conne=
ct
> doesn't ensure it gets called at every connection, so I need to override
> db_Main again. But how to do it preserving the funcionality under mod_per=
l2?

The simplest thing is fine here:

sub db_Main {
    my $self =3D shift;
    my $dbh =3D $self->SUPER::db_Main(@_);
... your stuff ...
}

Or if you want to be as efficient as possible you can override
_mk_db_closure from Ima::DBI to only do this when it opens a new
connection.  The db_Main() method is called VERY frequently in
Class::DBI.

- Perrin