Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-26371 sql - avoid distinct + text in glossary search

  • Loading branch information...
commit b37d06c2ed4879abaeecfbd5e365e64b5f5c66e1 1 parent f320cb7
@stronk7 stronk7 authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 mod/glossary/sql.php
View
14 mod/glossary/sql.php
@@ -134,6 +134,9 @@
default:
$sqlselect = "SELECT ge.*, ge.concept AS glossarypivot";
$sqlfrom = "FROM {glossary_entries} ge";
+ // For cases needing inner view
+ $sqlwrapheader = '';
+ $sqlwrapfooter = '';
$where = '';
$fullpivot = 0;
@@ -203,7 +206,13 @@
} else {
$searchcond = implode(" AND ", $searchcond);
- $sqlselect = "SELECT DISTINCT ge.*, ge.concept AS glossarypivot";
+ // Need one inner view here to avoid distinct + text
+ $sqlwrapheader = 'SELECT ge.*, ge.concept AS glossarypivot
+ FROM {glossary_entries} ge
+ JOIN ( ';
+ $sqlwrapfooter = ' ) gei ON (ge.id = gei.id)';
+
+ $sqlselect = "SELECT DISTINCT ge.id";
$sqlfrom = "FROM {glossary_entries} ge
LEFT JOIN {glossary_alias} al ON al.entryid = ge.id";
$where = "AND ($searchcond)";
@@ -262,5 +271,6 @@
$limitnum = $entriesbypage;
}
- $allentries = $DB->get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby", $params, $limitfrom, $limitnum);
+ $query = "$sqlwrapheader $sqlselect $sqlfrom $sqlwhere $sqlwrapfooter $sqlorderby";
+ $allentries = $DB->get_records_sql($query, $params, $limitfrom, $limitnum);
Please sign in to comment.
Something went wrong with that request. Please try again.