> > If I'm right, then something like this would stay shared:
> > 
> > our $dbh = DBI->connect(...);
> > $self->dbh_config($dbh);
> 
> But don't do that. It's just asking for problems. DB connections *will* 
> go stale. If that happens your application will stop working with 
> strange errors and only a restart will fix it. This is the problem that 
> Apache::DBI solves for mod_perl. If you want to learn how to do this on 
> your own, then I suggest looking in there for some pointers. But I will 
> warn you that Apache::DBI doesn't do the magic on it's own. DBI knows 
> about Apache::DBI. So any code you write yourself won't have that advantage.

Michael is right. The DBH plugin does have a way to cope with this, though.
Like this:

 our $dbh = sub { DBI->connect(...) }
 $self->dbh_config($dbh);

If we ever can't ping the connection, we'll call the code ref again and
re-connect.

I have personally used Apache::DBI/mod_perl for this in the past, but would
like to know that's there's a solution for FastCGI as well.

    Mark



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################

Reply via email to