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

This commit is contained in:
Eloy Lafuente (stronk7) 2011-02-12 17:05:32 +01:00
parent f320cb76c3
commit b37d06c2ed

View File

@ -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);