[LON-CAPA-cvs] cvs: modules /msu localenroll.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Mon, 07 Jan 2008 18:08:30 -0000


raeburn		Mon Jan  7 13:08:30 2008 EDT

  Modified files:              
    /modules/msu	localenroll.pm 
  Log:
  Need LIKE in place of equality in SQL query condition for last,first searches of type: "begins with" or "contains".
  
  
Index: modules/msu/localenroll.pm
diff -u modules/msu/localenroll.pm:1.33 modules/msu/localenroll.pm:1.34
--- modules/msu/localenroll.pm:1.33	Thu Jan  3 15:47:17 2008
+++ modules/msu/localenroll.pm	Mon Jan  7 13:08:28 2008
@@ -1,6 +1,6 @@
 # functions to glue school database system into Lon-CAPA for
 # automated enrollment
-# $Id: localenroll.pm,v 1.33 2008/01/03 20:47:17 raeburn Exp $
+# $Id: localenroll.pm,v 1.34 2008/01/07 18:08:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -574,15 +574,21 @@
             if ($srchtype eq 'contains') {
                 $quoted_last = $dbh->quote('%'.$srchlast.'%');
                 $quoted_first = $dbh->quote('%'.$srchfirst.'%');
+                $condition = "WHERE ( LastName LIKE $quoted_last AND ".
+                                     "FirstName LIKE $quoted_first )";
+
             } elsif ($srchtype eq 'begins') {
                 $quoted_last = $dbh->quote($srchlast.'%');
                 $quoted_first = $dbh->quote($srchfirst.'%');
+                $condition = "WHERE ( LastName LIKE $quoted_last AND ".
+                                    "FirstName LIKE $quoted_first )";
+
             } else {
                 $quoted_last = $dbh->quote($srchterm);
                 $quoted_first = $dbh->quote($srchterm);
+                $condition = "WHERE ( LastName = $quoted_last AND ".
+                                    "FirstName = $quoted_first )";
             }
-            $condition = "WHERE LastName = $quoted_last AND
-                                FirstName = $quoted_first";
         }
     } elsif ($srchby eq 'id') {
         if ($srchterm =~ /^[AZ]\d{8}$/) {