DBD-mysql - Re: mysql_auto_reconnect problems

Posted on Thu Jul 21 22:15:25 2005 by itub in response to 774 (See the whole thread of 8)
Re: mysql_auto_reconnect problems

In general, there is no problem with installing modules to a home directory. However, in the case of DBD::mysql, it can be tricky, because you need to compile it, and you need to have the mysql header files and libraries available. Some hosting providers don't provide compilers, which complicates things. If you have a system that is very similar to the one used by the hosting provider, you might be able to compile it at home and then just copy the files with some luck.

Other than that, perhaps you can work around it in your perl code by reconnecting explicitly. You can use $dbh->ping to check if the conection is live, and then reconnect if it's not. Since you need to check all the time, it would be a good idea to encapsulate $dbh in a method or subroutine. For example,

# untested code... sub dbh { my $self = shift; unless ($self->{dbh} and $self->{dbh}->ping) { $self->{dbh} = DBI->connect('dbi:mysql:test') or die "couldn't connect! "; } return $self->{dbh}; }
Direct Responses: 778 | Write a response