Hi
When using a MySQL database with modperl 2. I can find lots of docs on
using DBI, but not much on what is the best practice...
I am currently connecting, using the db and exiting on each request, and
relying on Apache::DBI to cache the connection. E.g.
use Apache::DBI;
sub handler {
# get db handle
my $dbh = DBI->connect(DB_URL, DB_USER, DB_PASSWD ....
#make some queries
my $lastKey = $dbh->prepare("SELECT LAST_INSERT_ID()");
#query
$lastKey->execute;
($key) = $lastKey->fetchrow_array();
#
}
If I understand Apache::DBI correctly, the DBI->connect picks up a
cached connection. Is it possible to prepare queries in one place and
reuse in all the child nodes? E.g. using prepare_cached. If so where do
I put that? In the startup file? In the same module?
Thanks in advance
Matt
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.