From f8b3cd4bdfb3e5d7d89005070a77bfc33f24a4f6 Mon Sep 17 00:00:00 2001 From: Jenny Gray Date: Tue, 1 Apr 2014 09:34:06 +0100 Subject: [PATCH] MDL-44021 mod_glossary - fixed search multiple keywords sql duplicate parameter error --- mod/glossary/sql.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php index 434cac2c3bf..28f372180fd 100644 --- a/mod/glossary/sql.php +++ b/mod/glossary/sql.php @@ -152,15 +152,6 @@ //$params = array(); $i = 0; - if (empty($fullsearch)) { - // With fullsearch disabled, look only within concepts and aliases. - $concat = $DB->sql_concat('ge.concept', "' '", "COALESCE(al.alias, :emptychar)"); - } else { - // With fullsearch enabled, look also within definitions. - $concat = $DB->sql_concat('ge.concept', "' '", 'ge.definition', "' '", "COALESCE(al.alias, :emptychar)"); - } - $params['emptychar'] = ''; - $searchterms = explode(" ",$hook); foreach ($searchterms as $searchterm) { @@ -169,8 +160,17 @@ $NOT = false; /// Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle /// will use it to simulate the "-" operator with LIKE clause - /// Under Oracle and MSSQL, trim the + and - operators and perform - /// simpler LIKE (or NOT LIKE) queries + if (empty($fullsearch)) { + // With fullsearch disabled, look only within concepts and aliases. + $concat = $DB->sql_concat('ge.concept', "' '", "COALESCE(al.alias, :emptychar".$i.")"); + } else { + // With fullsearch enabled, look also within definitions. + $concat = $DB->sql_concat('ge.concept', "' '", 'ge.definition', "' '", "COALESCE(al.alias, :emptychar".$i.")"); + } + $params['emptychar'.$i] = ''; + + /// Under Oracle and MSSQL, trim the + and - operators and perform + /// simpler LIKE (or NOT LIKE) queries if (!$DB->sql_regex_supported()) { if (substr($searchterm, 0, 1) == '-') { $NOT = true;