On 3/29/07, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:
If you need to connect on startup to pull configuration vars: a- connect before using Apache::DBI - not entirely necessary, but can avoid edge cases. b- connect using an alternate connection string 'user=myapp.config' - not entirely necessary, but can avoid edge cases. c- make sure you destroy the connection before init - entirely necessary
Apache::DBI handles this for you. It checks if you are connection during startup and does not make your connection persistent if you are. The problem here is that Helmut is caching the database handle himself, instead of calling DBI->connect on each request and letting Apache::DBI cache it. That foils Apache::DBI's attempts to prevent connections made in the parent from persisting. Caching database handles in your own object that persists across requests is usually a bad idea. It means that the things Apache::DBI tries to do for you (like ping'ing the connection to see if it's still good, and issuing a rollback after the request in case your code died during a transaction) will not happen. Don't do it unless you have a solid understanding of the problems Apache::DBI addresses and a plan for how to handle them yourself. - Perrin