in reply to Singletons, Apache::DBI and MySQL

Since you're using mod_perl's Apache::DBI, I don't see any reason for trying to store a persistent connection in your class. Apache::DBI already provides a persistent connection pool. I have the same setup as you(apache/mod_perl/mysql), I have one module that exports a function get_connection(), in all my other scripts I simply call get_connection(). The extra work you are doing won't be more efficient than that.

Replies are listed 'Best First'.
Re^2: Singletons, Apache::DBI and MySQL
by jbrugger (Parson) on Jan 03, 2005 at 08:02 UTC
    The reason i did this is the following:
    use strict; use DBH qw(&DBHOBJ); my $sth = DBHOBJ()->prepare('select blah from table;'); $sth->execute();
    Now the 'OLD' DBH just used Apche::DBI to return $self->{dbh};
    However, the MySQL server sometimes? coused the error "MySQL server has run away'.
    It was not able to reconnect, and the Apache::DBI module returned 1 on the implemented ping-method.