diff --git a/lib/datalib.php b/lib/datalib.php index cb4ee146683..9ae6b30a72d 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -80,6 +80,41 @@ function begin_sql() { } return true; } + +/** + * returns db specific uppercase function + */ +function db_uppercase() { + global $CFG; + switch (strtolower($CFG->dbtype)) { + + case "postgres7": + return "upper"; + break; + case "mysql": + default: + return "ucase"; + break; + } +} + +/** + * returns db specific lowercase function + */ +function db_lowercase() { + global $CFG; + switch (strtolower($CFG->dbtype)) { + + case "postgres7": + return "lower"; + break; + case "mysql": + default: + return "lcase"; + break; + } +} + /** * on DBs that support it, commit the transaction */ diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php index 4bc94c8e035..421461ca177 100644 --- a/mod/glossary/editcategories.php +++ b/mod/glossary/editcategories.php @@ -132,7 +132,8 @@ } elseif ( $action == "add" ) { if ( $confirm ) { - $dupcategory = get_record("glossary_categories","lcase(name)",strtolower($name),"glossaryid",$glossary->id); + $lcase = db_lowercase(); + $dupcategory = get_record("glossary_categories","$lcase(name)",strtolower($name),"glossaryid",$glossary->id); if ( $dupcategory ) { echo "
" . get_string("add"). " " . get_string("category","glossary") . "";