diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php
index 2e93b211b19..c83192d1802 100644
--- a/mod/glossary/editcategories.php
+++ b/mod/glossary/editcategories.php
@@ -158,8 +158,7 @@ if ( $hook >0 ) {
} elseif ( $action == "add" ) {
if ( $confirm ) {
- $ILIKE = $DB->sql_ilike();
- $dupcategory = $DB->get_records_sql("SELECT * FROM {glossary_categories} WHERE name $ILIKE ? AND glossaryid=?", array($name, $glossary->id));
+ $dupcategory = $DB->get_records_sql("SELECT * FROM {glossary_categories} WHERE ".$DB->sql_like('name','?', false)." AND glossaryid=?", array($name, $glossary->id));
if ( $dupcategory ) {
echo "
" . get_string("add"). " " . get_string("category","glossary"). "
";
diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php
index e79d636b8cb..b04b5c5ef8c 100644
--- a/mod/glossary/lib.php
+++ b/mod/glossary/lib.php
@@ -1200,7 +1200,6 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL)
$REGEXP = $DB->sql_regex(true);
$NOTREGEXP = $DB->sql_regex(false);
}
- $LIKE = $DB->sql_ilike(); // case-insensitive
$searchcond = array();
$params = array();
@@ -1212,14 +1211,14 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL)
foreach ($searchterms as $searchterm) {
$i++;
- $NOT = ''; /// Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle
+ $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 (!$DB->sql_regex_supported()) {
if (substr($searchterm, 0, 1) == '-') {
- $NOT = ' NOT ';
+ $NOT = true;
}
$searchterm = trim($searchterm, '+-');
}
@@ -1239,7 +1238,11 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL)
$params['ss'.$i] = "(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)";
} else {
- $searchcond[] = "$concat $NOT $LIKE :ss$i";
+ if ($NOT) {
+ $searchcond[] = "$concat NOT LIKE :ss$i"; //TODO: MDL-24080
+ } else {
+ $searchcond[] = $DB->sql_like($concat, ":ss$i", false);
+ }
$params['ss'.$i] = "%$searchterm%";
}
}
diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php
index 9888f2730c4..6349de2e1db 100644
--- a/mod/glossary/sql.php
+++ b/mod/glossary/sql.php
@@ -145,7 +145,6 @@
$REGEXP = $DB->sql_regex(true);
$NOTREGEXP = $DB->sql_regex(false);
}
- $LIKE = $DB->sql_ilike(); // case-insensitive
$searchcond = array();
$alcond = array();
@@ -159,14 +158,14 @@
foreach ($searchterms as $searchterm) {
$i++;
- $NOT = ''; /// Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle
+ $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 (!$DB->sql_regex_supported()) {
if (substr($searchterm, 0, 1) == '-') {
- $NOT = ' NOT ';
+ $NOT = true;
}
$searchterm = trim($searchterm, '+-');
}
@@ -193,13 +192,17 @@
if ($textlib->strlen($searchterm) < 2) {
continue;
}
- $searchcond[] = "$concat $NOT $LIKE :ss$i";
+ if ($NOT) {
+ $searchcond[] = "$concat NOT LIKE :ss$i"; //TODO: MDL-24080
+ } else {
+ $searchcond[] = $DB->sql_like($concat, ":ss$i", false);
+ }
$params['ss'.$i] = "%$searchterm%";
}
}
if (empty($searchcond)) {
- $where = " 1=2 "; // no search result
+ $where = "AND 1=2 "; // no search result
} else {
$searchcond = implode(" AND ", $searchcond);