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

bowersj2 lon-capa-cvs@mail.lon-capa.org
Sat, 04 Feb 2006 20:03:30 -0000


bowersj2		Sat Feb  4 15:03:30 2006 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
  Log:
  * If the SQL fails to become a $sth, try to provide a better error
  message.
  
  * Correct an SQL query that needed an "AS a" in it. This should never
  have worked; this may have failed on my system because I recently
  upgraded to MySQL 5.
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.151 loncom/interface/loncoursedata.pm:1.152
--- loncom/interface/loncoursedata.pm:1.151	Fri Nov 11 18:23:24 2005
+++ loncom/interface/loncoursedata.pm	Sat Feb  4 15:03:30 2006
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.151 2005/11/11 23:23:24 albertel Exp $
+# $Id: loncoursedata.pm,v 1.152 2006/02/04 20:03:30 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1873,6 +1873,8 @@
     my ($dbh,$request)=@_;
 #    &Apache::lonnet::logthis($request);
     my $sth = $dbh->prepare($request);
+    if (!$sth)
+    { die $dbh->errstr . " SQL: $request"; }
     $sth->execute();
     my $row = $sth->fetchrow_arrayref();
     if (ref($row) eq 'ARRAY' && scalar(@$row)>0) {
@@ -2212,7 +2214,7 @@
 #    &Apache::lonnet::logthis('request = '.$/.$request);
     
     $request = 'SELECT SUM(weight) FROM '.$weight_table.
-        ' WHERE ('.$symb_restriction.')';
+        ' AS a WHERE ('.$symb_restriction.')';
     my ($max_possible) = &execute_SQL_request($dbh,$request);
     # &Apache::lonnet::logthis('request = '.$/.$request);
     return($min,$max,$ave,$std,$count,$max_possible);