Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moodle--eduforge--1.3.3--patch-159 get_courses checks to see if sort …

…is not empty before putting it in the query + removal of redundant (and costly) SQL SELECT
  • Loading branch information...
commit b55be229e92f2dbc059d8f05f906d5a036441850 1 parent 96522de
martinlanghoff authored
Showing with 1 addition and 3 deletions.
  1. +1 −3 lib/datalib.php
View
4 lib/datalib.php
@@ -1787,8 +1787,6 @@ function get_courses($categoryid="all", $sort="c.sortorder ASC", $fields="c.*")
$selectsql = "{$CFG->prefix}course c $teachertable";
}
- $courses = get_records_sql("SELECT $fields FROM $selectsql ORDER BY $sort");
-
return get_records_sql("SELECT ".((!empty($teachertable)) ? " DISTINCT " : "")." $fields FROM $selectsql ".((!empty($sort)) ? "ORDER BY $sort" : ""));
}
@@ -1964,7 +1962,7 @@ function get_courses_search($searchterms, $sort="fullname ASC", $page=0, $record
$totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
- $courses = get_records_sql("SELECT * FROM $selectsql ORDER BY $sort $limit");
+ $courses = get_records_sql("SELECT * FROM $selectsql ".((!empty($sort)) ? "ORDER BY $sort" : "")." $limit");
if ($courses) { /// Remove unavailable courses from the list
foreach ($courses as $key => $course) {
Please sign in to comment.
Something went wrong with that request. Please try again.