]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17130 dml: eliminated $CFG->dbfamily
authorskodak <skodak>
Wed, 5 Nov 2008 00:12:30 +0000 (00:12 +0000)
committerskodak <skodak>
Wed, 5 Nov 2008 00:12:30 +0000 (00:12 +0000)
admin/innodb.php
lib/accesslib.php
lib/db/upgrade.php
lib/searchlib.php
mod/data/field/latlong/field.class.php
mod/data/field/number/field.class.php
mod/forum/search.php
mod/wiki/ewikimoodlelib.php
search/lib.php

index 93238106cb1afd6f3f01380e0b87c033b4271caa..98e7991e295f6d88d418f05fa8fad745a6caf61f 100644 (file)
@@ -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');
     }
 
index c37780b0a69dc98b27f3b9d0c41444999a7f179b..a091621e6c0bb5add5c83544eb8fd1f2dc6d5546 100755 (executable)
@@ -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
index 862e8e5a73d8bc17fd59ec5ef40f94fd4c9eee98..fd5a0ebf3ac58644e0bbec14394b0c3d87b121c8 100644 (file)
@@ -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");
         }
 
index 7343afa945836507f23d294747b5e8d2f1e20453..ceb462d5f8e20d42add97c40f0ceab740803f8da 100644 (file)
@@ -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,
index 9985c84d145b96077623510d8f804ce3b8d3148b..87ed62a7d40d1f27c3689ebaddc830e1a43f6068 100755 (executable)
@@ -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)';
index 23835e29a9972b5339233acc73d9319c1ebfbcea..1fe18c933f0e833132803d7a174ae3d35e7a1f8a 100755 (executable)
@@ -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)';
index 95bf7b2bb646050709ff8a3fd9b012a9b30e30d2..3d4b6d7ecab8f91f89b68d8df848dbc95948cdd5 100644 (file)
  * @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 '<td class="c1"><input type="text" size="35" name="notwords" id="notwords" value="'.s($notwords, true).'" alt="" /></td>';
     echo '</tr>';
 
-    if ($CFG->dbfamily == 'mysql' || $CFG->dbfamily == 'postgres') {
+    if ($DB->get_db_family() == 'mysql' || $DB->get_db_family() == 'postgres') {
         echo '<tr>';
         echo '<td class="c0"><label for="fullwords">'.get_string('searchfullwords', 'forum').'</label></td>';
         echo '<td class="c1"><input type="text" size="35" name="fullwords" id="fullwords" value="'.s($fullwords, true).'" alt="" /></td>';
index 97b3bd8fbddceef980c0469a153aaf601c2b0951..af044e53d640b390a0ebc3a93166b25c816e6def 100644 (file)
@@ -191,7 +191,7 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
           array("flags","meta","lastmodified");
       */
       case "GETALL":
-         switch ($CFG->dbfamily) {
+         switch ($DB->get_db_family()) {
              case 'postgres':
                  // All but the latest version eliminated by DISTINCT
                  // ON (pagename)
index b715d2ad53dd88e065fca1790c25993b636a5cf3..6706fc3e78a2d1ead04e5d5124a99594d56bc8b1 100644 (file)
@@ -23,7 +23,6 @@ function search_get_document_types($prefix = 'SEARCH_TYPE_') {
 function search_get_document_types($prefix = 'X_SEARCH_TYPE_') {
 function search_get_additional_modules() {
 function search_shorten_url($url, $length=30) {
-function search_escape_string($str) {
 function search_stopwatch($cli = false) {
 function search_pexit($str = "") {
 */
@@ -153,27 +152,6 @@ function search_shorten_url($url, $length=30) {
     return substr($url, 0, $length)."...";
 } //search_shorten_url
 
-/**
-* a local function for escaping
-* @param str the string to escape
-* @return the escaped string
-*/
-function search_escape_string($str) {
-    global $CFG;
-
-    switch ($CFG->dbfamily) {
-        case 'mysql':
-            $s = mysql_real_escape_string($str);
-            break;
-        case 'postgres':
-            $s = pg_escape_string($str);
-            break;
-        default:
-            $s = addslashes($str);
-    }
-    return $s;
-} //search_escape_string
-
 /**
 * simple timer function, on first call, records a current microtime stamp, outputs result on 2nd call
 * @param cli an output formatting switch