]> git.mjollnir.org Git - moodle.git/commitdiff
Some more uses of $CFG->dbfamily. MDL-7061
authorstronk7 <stronk7>
Sat, 13 Jan 2007 00:09:02 +0000 (00:09 +0000)
committerstronk7 <stronk7>
Sat, 13 Jan 2007 00:09:02 +0000 (00:09 +0000)
lib/searchlib.php
lib/setuplib.php
lib/simpletestlib.php
lib/statslib.php
message/lib.php

index 0e15c496ad6a460d4a03525afa49a28626b138b4..4f74d923e4c372cc692ca40fbcf773935fcbe6ef 100644 (file)
@@ -316,7 +316,7 @@ function search_generate_SQL($parsetree, $datafield, $metafield, $mainidfield, $
 
     $LIKE = sql_ilike();
     $NOTLIKE = 'NOT ' . $LIKE;
-    if ($CFG->dbtype == "postgres7") {
+    if ($CFG->dbfamily == "postgres") {
         $REGEXP = "~*";
         $NOTREGEXP = "!~*";
     } else {
@@ -340,7 +340,7 @@ function search_generate_SQL($parsetree, $datafield, $metafield, $mainidfield, $
         $value = $parsetree[$i]->getValue();
 
     /// Under Oracle and MSSQL, transform TOKEN searches into STRING searches and trim +- chars
-        if ($CFG->dbtype == 'oci8po' || $CFG->dbtype == 'mssql' || $CFG->dbtype == 'mssql_n' || $CFG->dbtype == 'odbc_mssql') {
+        if ($CFG->dbfamily == 'oracle' || $CFG->dbfamily == 'mssql') {
             $value = trim($value, '+-');
             if ($type == TOKEN_EXACT) {
                 $type = TOKEN_STRING;
index 533c0fc7addb9c032045b3c92576fd97395edcad..788bfad9b15d9c1bf7a9c2e8b297e978f0a86005 100644 (file)
@@ -160,17 +160,11 @@ function setup_is_unicodedb() {
 
     $unicodedb = false;
     
-    // Since this function is also used during installation process, i.e. during install.php before $CFG->dbtype is set.
-    // we need to get dbtype from the right variable 
-    if (!empty($INSTALL['dbtype'])) {
-        $dbtype = $INSTALL['dbtype'];
-    } else {
-        $dbtype = $CFG->dbtype;
-    }
+    // Calculate $CFG->dbfamily
+    $dbfamily = set_dbfamily();
 
-    switch ($dbtype) {
+    switch ($dbfamily) {
         case 'mysql':
-        case 'mysqli':
             $rs = $db->Execute("SHOW VARIABLES LIKE 'character_set_database'");
             if ($rs && $rs->RecordCount() > 0) {
                 $records = $rs->GetAssoc(true);
@@ -180,7 +174,7 @@ function setup_is_unicodedb() {
                 }
             }
             break;
-        case 'postgres7':
+        case 'postgres':
         /// Get PostgreSQL server_encoding value
             $rs = $db->Execute("SHOW server_encoding");
             if ($rs && $rs->RecordCount() > 0) {
@@ -191,12 +185,10 @@ function setup_is_unicodedb() {
             }
             break;
         case 'mssql':
-        case 'mssql_n':
-        case 'odbc_mssql':
         /// MSSQL only runs under UTF8 + the proper ODBTP driver (both for Unix and Win32)
             $unicodedb = true;
             break;
-        case 'oci8po':
+        case 'oracle':
         /// Get Oracle DB character set value
             $rs = $db->Execute("SELECT parameter, value FROM nls_database_parameters where parameter = 'NLS_CHARACTERSET'");
             if ($rs && $rs->RecordCount() > 0) {
index d6cdc509aa3cf27059fc7ad1daae498407fe2bf6..2206efcc45e9d0a557d4e49cd35ce64c03b9a4d0 100644 (file)
@@ -218,7 +218,7 @@ function load_test_data($tablename, $data, $localdb = null) {
             $maxid = $row[$idcol];
         }
     }
-    if ($CFG->dbtype == 'postgres7' && $idcol !== false) {
+    if ($CFG->dbfamily == 'postgres' && $idcol !== false) {
         $maxid += 1;
         _private_execute_sql("ALTER SEQUENCE {$tablename}_id_seq RESTART WITH $maxid;", $localdb);
     }
@@ -289,7 +289,7 @@ function remove_test_table($tablename, $db, $cascade = false) {
     global $CFG;
     _private_execute_sql('DROP TABLE ' . $tablename . ($cascade ? ' CASCADE' : '') . ';', $db);
     
-    if ($CFG->dbtype == 'postgres7') {
+    if ($CFG->dbfamily == 'postgres') {
         $rs = $db->Execute("SELECT relname FROM pg_class WHERE relname = '{$tablename}_id_seq' AND relkind = 'S';");
         if ($rs && $rs->RecordCount()) {
             _private_execute_sql("DROP SEQUENCE {$tablename}_id_seq;", $db);
@@ -329,7 +329,7 @@ function wipe_tables($prefix, $db) {
 function wipe_sequences($prefix, $db) {
     global $CFG;
 
-    if ($CFG->dbtype == 'postgres7') {
+    if ($CFG->dbfamily == 'postgres') {
         $sequences = $db->GetCol("SELECT relname FROM pg_class WHERE relname LIKE '$prefix%_id_seq' AND relkind = 'S';");
         if ($sequences) {
             foreach ($sequences as $sequence) {
@@ -385,4 +385,4 @@ class prefix_changing_test_case extends UnitTestCase {
         $this->change_prefix_back();
     }
 }
-?>
\ No newline at end of file
+?>
index e9c29c3ef7d9183fa3a9dc22fa008ab6540201a8..2c6d66dcba6c94c03ae57cc112e4d45745b73a2a 100644 (file)
@@ -563,7 +563,7 @@ function stats_get_parameters($time,$report,$courseid,$mode,$roleid=0) {
 
     // compatibility - if we're in postgres, cast to real for some reports.
     $real = '';
-    if ($CFG->dbtype == 'postgres7') {
+    if ($CFG->dbfamily == 'postgres') {
         $real = '::real';
     }
 
index ec95cd6cdcb68430b8534e350eaff672485cd8bd..5e9ff991190c0ef22d9bc3078c4d7ccb234d52e3 100644 (file)
@@ -740,7 +740,7 @@ function message_search($searchterms, $fromme=true, $tome=true, $courseid='none'
     /// Some differences in SQL syntax
     $LIKE = sql_ilike();
     $NOTLIKE = 'NOT ' . $LIKE;
-    if ($CFG->dbtype == "postgres7") {
+    if ($CFG->dbfamily == "postgres") {
         $REGEXP = "~*";
         $NOTREGEXP = "!~*";
     } else {
@@ -756,7 +756,7 @@ function message_search($searchterms, $fromme=true, $tome=true, $courseid='none'
         }
     /// Under Oracle and MSSQL, trim the + and - operators and perform
     /// simpler LIKE search
-        if ($CFG->dbtype == 'oci8po' || $CFG->dbtype == 'mssql' || $CFG->dbtype == 'mssql_n' || $CFG->dbtype == 'odbc_mssql') {
+        if ($CFG->dbfamily == 'oracle' || $CFG->dbfamily == 'mssql') {
             $searchterm = trim($searchterm, '+-');
         }