[CDBI] Class::DBI and mod_perl

Perrin Harkins perrin at elem.com
Tue Nov 21 23:20:27 GMT 2006


john drago wrote:
> One thing I found was to ignore the documentation where it says to override the 
> db_Main method with your own.

Don't do that.  If you let Class::DBI handle the connections for you, 
you are likely to run into problems.  It breaks the automatic safety 
rollback that Apache::DBI does for you after every request (very 
important if you use any transactions or table locks), and it keeps 
connections that you open during startup (maybe unintentionally, by 
doing a set_up_table() call) open across the apache fork, which will 
cause socket errors.  That's why you get some broken connections after a 
restart.

> That caused endless problems.

If you could describe them, maybe someone here will know how to fix them.

There are other ways to do it than the code shown on the wiki, but the 
standard Class::DBI approach is considerably less safe than Apache::DBI.

- Perrin



More information about the ClassDBI mailing list