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');
}
*
* 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
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
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");
}
*/
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,
}
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)';
}
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)';
* @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');
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>';
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)
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 = "") {
*/
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