[CDBI] Ima::DBI and mod_perl2

Perrin Harkins perrin at elem.com
Wed Nov 3 19:35:57 GMT 2010


On Wed, Nov 3, 2010 at 12:28 PM, Michele Valzelli
<spleen.leveller at gmail.com> wrote:
> Just putting
> the Your_CDBI::Class->db_Main->do($sql_statement); line after the connect
> 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_perl2?

The simplest thing is fine here:

sub db_Main {
    my $self = shift;
    my $dbh = $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



More information about the ClassDBI mailing list