gradebook MDL-25769 switched a query over to use named params
authorandyjdavis <andrew@moodle.com>
Mon, 10 Jan 2011 04:04:51 +0000 (12:04 +0800)
committerSam Hemelryk <sam@moodle.com>
Tue, 18 Jan 2011 03:56:20 +0000 (11:56 +0800)
grade/import/lib.php
grade/report/grader/lib.php

index 8d7463b..331a80a 100644 (file)
@@ -181,11 +181,11 @@ function get_unenrolled_users_in_import($importcode, $courseid) {
                 LEFT JOIN {role_assignments} ra ON (giv.userid = ra.userid AND
                     ra.roleid $gradebookrolessql AND
                     ra.contextid $relatedctxcondition)
-                WHERE giv.importcode = ?
+                WHERE giv.importcode = :importcode
                     AND (ra.id IS NULL OR je.id IS NULL)
                 ORDER BY gradeidnumber, u.lastname, u.firstname";
     $params = array_merge($gradebookrolesparams, $enrolledparams);
-    $params[] = $importcode;
+    $params['importcode'] = $importcode;
 
     return $DB->get_records_sql($sql, $params);
 }
index e90c491..5c591ce 100644 (file)
@@ -349,17 +349,17 @@ class grade_report_grader extends grade_report {
             $sort = "MAX(g.finalgrade) $this->sortorder";
 
             $sql = "SELECT $userfields
-                    FROM {user} u
-                        JOIN ($enrolledsql) je ON je.id = u.id
-                        JOIN {role_assignments} ra ON ra.userid = u.id
-                        $this->groupsql
-                        LEFT JOIN {grade_grades} g ON (g.userid = u.id AND g.itemid = :gitemid)
-                    WHERE ra.roleid $gradebookrolessql
-                        AND u.deleted = 0
-                        AND ra.contextid ".get_related_contexts_string($this->context)."
-                        $this->groupwheresql
-                    GROUP BY $userfields
-                    ORDER BY $sort";
+                      FROM {user} u
+                           JOIN ($enrolledsql) je ON je.id = u.id
+                           JOIN {role_assignments} ra ON ra.userid = u.id
+                           $this->groupsql
+                           LEFT JOIN {grade_grades} g ON (g.userid = u.id AND g.itemid = :gitemid)
+                     WHERE ra.roleid $gradebookrolessql
+                           AND u.deleted = 0
+                           AND ra.contextid ".get_related_contexts_string($this->context)."
+                           $this->groupwheresql
+                  GROUP BY $userfields
+                  ORDER BY $sort";
 
         } else {
             switch($this->sortitemid) {
@@ -375,15 +375,15 @@ class grade_report_grader extends grade_report {
             $params = array_merge($gradebookrolesparams, $this->groupwheresql_params, $enrolledparams);
 
             $sql = "SELECT DISTINCT $userfields
-                    FROM {user} u
-                        JOIN ($enrolledsql) je ON je.id = u.id
-                        JOIN {role_assignments} ra ON u.id = ra.userid
-                        $this->groupsql
-                    WHERE ra.roleid $gradebookrolessql 
-                        AND u.deleted = 0
-                        AND ra.contextid ".get_related_contexts_string($this->context)."
-                        $this->groupwheresql
-                    ORDER BY $sort";
+                      FROM {user} u
+                           JOIN ($enrolledsql) je ON je.id = u.id
+                           JOIN {role_assignments} ra ON u.id = ra.userid
+                           $this->groupsql
+                     WHERE ra.roleid $gradebookrolessql 
+                           AND u.deleted = 0
+                           AND ra.contextid ".get_related_contexts_string($this->context)."
+                           $this->groupwheresql
+                  ORDER BY $sort";
         }