Permalink
Browse files

gradebook MDL-25769 switched a query over to use named params

  • Loading branch information...
1 parent 2dc5e58 commit f2491a11a1a00c0ebaaba6aa1e2b5e34f2652a74 @andyjdavis andyjdavis committed with Sam Hemelryk Jan 10, 2011
Showing with 22 additions and 22 deletions.
  1. +2 −2 grade/import/lib.php
  2. +20 −20 grade/report/grader/lib.php
View
@@ -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);
}
@@ -349,17 +349,17 @@ public function load_users() {
$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 @@ public function load_users() {
$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";
}

0 comments on commit f2491a1

Please sign in to comment.