--- loncom/interface/lonmysql.pm 2003/03/17 18:35:51 1.11 +++ loncom/interface/lonmysql.pm 2003/04/18 15:50:55 1.13 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # MySQL utility functions # -# $Id: lonmysql.pm,v 1.11 2003/03/17 18:35:51 matthew Exp $ +# $Id: lonmysql.pm,v 1.13 2003/04/18 15:50:55 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -348,6 +348,33 @@ sub connect_to_db { =pod +=item &verify_sql_connection() + +Inputs: none. + +Returns: 0 (failure) or 1 (success) + +Checks to make sure the database can be connected to. It does not +initialize anything in the lonmysql package. + +=cut + +############################### +sub verify_sql_connection { + my $connection; + if (! ($connection = DBI->connect("DBI:mysql:loncapa","www", + $Apache::lonnet::perlvar{'lonSqlAccess'}, + { RaiseError=>0,PrintError=>0}))) { + return 0; + } + undef($connection); + return 1; +} + +############################### + +=pod + =item &disconnect_from_db() Inputs: none. @@ -981,6 +1008,7 @@ sub remove_from_table { $errorstring = "ERROR on execution of ".$command."\n".$sth->errstr; return undef; } + $debugstring = $command; my $rows = $sth->rows; return $rows; }