[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to use Apache::DBI


On 7/31/07, Clinton Gormley <suppressed> wrote:
> What you could do instead is to use DBI's connect_cached method, which
> provides similar functionality.  I actually use this instead of
> Apache::DBI, even when running under mod_perl.

I also use connect_cached in many cases.  Just be aware of what you're
missing out on, because Apache::DBI does some extra things to protect
you.

Here are the main differences:
- Apache::DBI doesn't require code changes.  connect_cached() does.
- Apache::DBI will avoid caching a connection that you open during
server startup, so that you don't accidentally try to use the same
connection in multiple processes (due to forking).
- Apache::DBI issues an automatic rollback at the end of every
request, so that if your code dies while it has a transaction going,
that will be freed before the next request.  (This is only if you open
your handles with AutoCommit off though.)

Hmm, maybe this should be in the Apache::DBI documentation.

- Perrin


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.