diff --git a/admin/innodb.php b/admin/innodb.php index 93238106cb1..98e7991e295 100644 --- a/admin/innodb.php +++ b/admin/innodb.php @@ -14,7 +14,7 @@ admin_externalpage_print_header(); print_heading('Convert all MySQL tables from MYISAM to InnoDB'); - if ($CFG->dbfamily != 'mysql') { + if ($DB->get_dbfamily() != 'mysql') { notice('This function is for MySQL databases only!', 'index.php'); } diff --git a/lib/accesslib.php b/lib/accesslib.php index c37780b0a69..a091621e6c0 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -5352,12 +5352,13 @@ function build_context_path($force=false) { * * Different code for each database - mostly for performance reasons */ - if ($CFG->dbfamily == 'mysql') { + $dbfamily = $DB->get_dbfamily(); + if ($dbfamily == 'mysql') { $updatesql = "UPDATE {context} ct, {context_temp} temp SET ct.path = temp.path, ct.depth = temp.depth WHERE ct.id = temp.id"; - } else if ($CFG->dbfamily == 'oracle') { + } else if ($dbfamily == 'oracle') { $updatesql = "UPDATE {context} ct SET (ct.path, ct.depth) = (SELECT temp.path, temp.depth @@ -5366,7 +5367,7 @@ function build_context_path($force=false) { WHERE EXISTS (SELECT 'x' FROM {context_temp} temp WHERE temp.id = ct.id)"; - } else if ($CFG->dbfamily == 'postgres' or $CFG->dbfamily == 'mssql') { + } else if ($dbfamily == 'postgres' or $dbfamily == 'mssql') { $updatesql = "UPDATE {context} SET path = temp.path, depth = temp.depth diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 862e8e5a73d..fd5a0ebf3ac 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -93,7 +93,8 @@ function xmldb_main_upgrade($oldversion) { upgrade_set_timeout(60*20); // this may take a while /// Under MySQL and Postgres... detect old NULL contents and change them by correct empty string. MDL-14859 - if ($CFG->dbfamily == 'mysql' || $CFG->dbfamily == 'postgres') { + $dbfamily = $DB->get_dbfamily(); + if ($dbfamily === 'mysql' || $dbfamily === 'postgres') { $DB->execute("UPDATE {user} SET idnumber = '' WHERE idnumber IS NULL"); } diff --git a/lib/searchlib.php b/lib/searchlib.php index 7343afa9458..ceb462d5f8e 100644 --- a/lib/searchlib.php +++ b/lib/searchlib.php @@ -313,19 +313,19 @@ class search_parser { */ function search_generate_text_SQL($parsetree, $datafield, $metafield, $mainidfield, $useridfield, $userfirstnamefield, $userlastnamefield, $timefield, $instancefield) { - global $CFG; + global $CFG, $DB; static $p = 0; /// First of all, search for reasons to switch to standard SQL generation /// Only mysql are supported for now - if ($CFG->dbfamily != 'mysql') { + if ($DB->get_db_family() != 'mysql') { return search_generate_SQL($parsetree, $datafield, $metafield, $mainidfield, $useridfield, $userfirstnamefield, $userlastnamefield, $timefield, $instancefield); } /// Some languages don't have "word separators" and MySQL FULLTEXT doesn't perform well with them, so /// switch to standard SQL search generation - if ($CFG->dbfamily == 'mysql') { + if ($DB->get_db_family() == 'mysql') { $nonseparatedlangs = array('ja_utf8', 'th_utf8', 'zh_cn_utf8', 'zh_tw_utf8'); if (in_array(current_language(), $nonseparatedlangs)) { return search_generate_SQL($parsetree, $datafield, $metafield, $mainidfield, $useridfield, diff --git a/mod/data/field/latlong/field.class.php b/mod/data/field/latlong/field.class.php index 9985c84d145..87ed62a7d40 100755 --- a/mod/data/field/latlong/field.class.php +++ b/mod/data/field/latlong/field.class.php @@ -193,8 +193,8 @@ class data_field_latlong extends data_field_base { } function get_sort_sql($fieldname) { - global $CFG; - switch ($CFG->dbfamily) { + global $DB; + switch ($DB->get_db_family()) { case 'mysql': // string in an arithmetic operation is converted to a floating-point number return '('.$fieldname.'+0.0)'; diff --git a/mod/data/field/number/field.class.php b/mod/data/field/number/field.class.php index 23835e29a99..1fe18c933f0 100755 --- a/mod/data/field/number/field.class.php +++ b/mod/data/field/number/field.class.php @@ -86,8 +86,8 @@ class data_field_number extends data_field_base { } function get_sort_sql($fieldname) { - global $CFG; - switch ($CFG->dbfamily) { + global $DB; + switch ($DB->get_db_family()) { case 'mysql': // string in an arithmetic operation is converted to a floating-point number return '('.$fieldname.'+0.0)'; diff --git a/mod/forum/search.php b/mod/forum/search.php index 95bf7b2bb64..3d4b6d7ecab 100644 --- a/mod/forum/search.php +++ b/mod/forum/search.php @@ -246,7 +246,7 @@ * @todo Document this function */ function forum_print_big_search_form($course) { - global $CFG, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto; + global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto; print_simple_box(get_string('searchforumintro', 'forum'), 'center', '', '', 'searchbox', 'intro'); @@ -276,7 +276,7 @@ function forum_print_big_search_form($course) { echo '