[LON-CAPA-cvs] cvs: loncom /interface lonmysql.pm

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 03 Mar 2004 17:19:06 -0000


matthew		Wed Mar  3 12:19:06 2004 EDT

  Modified files:              
    /loncom/interface	lonmysql.pm 
  Log:
  For some reason we occasionally need to execute the 'SHOW TABLES' call
  twice in &tables_in_db().
  
  
Index: loncom/interface/lonmysql.pm
diff -u loncom/interface/lonmysql.pm:1.18 loncom/interface/lonmysql.pm:1.19
--- loncom/interface/lonmysql.pm:1.18	Sat Dec 27 11:58:36 2003
+++ loncom/interface/lonmysql.pm	Wed Mar  3 12:19:06 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # MySQL utility functions
 #
-# $Id: lonmysql.pm,v 1.18 2003/12/27 16:58:36 www Exp $
+# $Id: lonmysql.pm,v 1.19 2004/03/03 17:19:06 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -932,18 +932,20 @@
     return undef if (!defined(&connect_to_db()));
     my $sth=$dbh->prepare('SHOW TABLES');
     $sth->execute();
-    if ($sth->err) {
-        $errorstring = "$dbh ATTEMPTED:\n".'SHOW TABLES'.
+    $sth->execute();
+    my $aref = $sth->fetchall_arrayref;
+    if ($sth->err()) {
+        $errorstring = 
+            "$dbh ATTEMPTED:\n".'fetchall_arrayref after SHOW TABLES'.
             "\nRESULTING ERROR:\n".$sth->errstr;
         return undef;
     }
-    my $aref = $sth->fetchall_arrayref;
-    my @table_list=();
+    my @table_list;
     foreach (@$aref) {
-        push @table_list,$_->[0];
+        push(@table_list,$_->[0]);
     }
-    $debugstring = "Got list of tables in DB: @table_list";
-    return @table_list;
+    $debugstring = "Got list of tables in DB: ".join(',',@table_list);
+    return(@table_list);
 }
 
 ###########################################