From: stronk7 Date: Sat, 13 Jan 2007 00:09:02 +0000 (+0000) Subject: Some more uses of $CFG->dbfamily. MDL-7061 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=bb48a537359e1ba96c76511374500877358c6b7e;p=moodle.git Some more uses of $CFG->dbfamily. MDL-7061 --- diff --git a/lib/searchlib.php b/lib/searchlib.php index 0e15c496ad..4f74d923e4 100644 --- a/lib/searchlib.php +++ b/lib/searchlib.php @@ -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; diff --git a/lib/setuplib.php b/lib/setuplib.php index 533c0fc7ad..788bfad9b1 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -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) { diff --git a/lib/simpletestlib.php b/lib/simpletestlib.php index d6cdc509aa..2206efcc45 100644 --- a/lib/simpletestlib.php +++ b/lib/simpletestlib.php @@ -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 +?> diff --git a/lib/statslib.php b/lib/statslib.php index e9c29c3ef7..2c6d66dcba 100644 --- a/lib/statslib.php +++ b/lib/statslib.php @@ -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'; } diff --git a/message/lib.php b/message/lib.php index ec95cd6cdc..5e9ff99119 100644 --- a/message/lib.php +++ b/message/lib.php @@ -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, '+-'); }