mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-17130 dml: eliminated $CFG->dbfamily
This commit is contained in:
parent
ba98912f8c
commit
cbc08f3bfc
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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)';
|
||||
|
@ -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)';
|
||||
|
@ -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 '<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>';
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user