Aligned SQL to conform to Moodle standards

This commit is contained in:
Mark Nelson 2015-03-11 01:22:44 -07:00
parent 8a55c96dab
commit 6821122c30
6 changed files with 44 additions and 47 deletions

View file

@ -304,8 +304,7 @@ function customcert_delete_page($pageid) {
SET pagenumber = pagenumber - 1 SET pagenumber = pagenumber - 1
WHERE customcertid = :customcertid WHERE customcertid = :customcertid
AND pagenumber > :pagenumber"; AND pagenumber > :pagenumber";
$DB->execute($sql, array('customcertid' => $page->customcertid, $DB->execute($sql, array('customcertid' => $page->customcertid, 'pagenumber' => $page->pagenumber));
'pagenumber' => $page->pagenumber));
} }
/** /**
@ -407,17 +406,15 @@ function customcert_get_issues($customcertid, $groupmode, $cm, $page, $perpage)
$allparams = $conditionsparams + array('customcertid' => $customcertid); $allparams = $conditionsparams + array('customcertid' => $customcertid);
// Return the issues. // Return the issues.
return $DB->get_records_sql("SELECT u.*, ci.code, ci.timecreated $sql = "SELECT u.*, ci.code, ci.timecreated
FROM {user} u FROM {user} u
INNER JOIN {customcert_issues} ci INNER JOIN {customcert_issues} ci
ON u.id = ci.userid ON u.id = ci.userid
WHERE u.deleted = 0 WHERE u.deleted = 0
AND ci.customcertid = :customcertid AND ci.customcertid = :customcertid
$conditionssql $conditionssql
ORDER BY " . $DB->sql_fullname(), ORDER BY " . $DB->sql_fullname();
$allparams, return $DB->get_records_sql($sql, $allparams, $page * $perpage, $perpage);
$page * $perpage,
$perpage);
} }
/** /**
@ -438,14 +435,14 @@ function customcert_get_number_of_issues($customcertid, $cm, $groupmode) {
$allparams = $conditionsparams + array('customcertid' => $customcertid); $allparams = $conditionsparams + array('customcertid' => $customcertid);
// Return the number of issues. // Return the number of issues.
return $DB->count_records_sql("SELECT COUNT(u.id) as count $sql = "SELECT COUNT(u.id) as count
FROM {user} u FROM {user} u
INNER JOIN {customcert_issues} ci INNER JOIN {customcert_issues} ci
ON u.id = ci.userid ON u.id = ci.userid
WHERE u.deleted = 0 WHERE u.deleted = 0
AND ci.customcertid = :customcertid AND ci.customcertid = :customcertid
$conditionssql", $conditionssql";
$allparams); return $DB->count_records_sql($sql, $allparams);
} }
/** /**