mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
added code to support dummy fields (to enable dropping and adding arbitray number of indexes)
This commit is contained in:
parent
e70813cf37
commit
a03d69a5ea
1 changed files with 22 additions and 10 deletions
|
@ -1,4 +1,6 @@
|
||||||
<?
|
<?
|
||||||
|
///dummy field names are used to help adding and dropping indexes. There's only 1 case now, in scorm_scoes_track
|
||||||
|
|
||||||
function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||||
//pointing to the num of records to process would be
|
//pointing to the num of records to process would be
|
||||||
//useful. And it won't break anything, because the
|
//useful. And it won't break anything, because the
|
||||||
|
@ -149,9 +151,11 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||||
$addprimary = $field['@']['addprimary'];
|
$addprimary = $field['@']['addprimary'];
|
||||||
$defaults[] = isset($field['@']['default'])?"'".$field['@']['default']."'":"''";
|
$defaults[] = isset($field['@']['default'])?"'".$field['@']['default']."'":"''";
|
||||||
|
|
||||||
|
if ($fieldname != 'dummy') {
|
||||||
$colnames[] = $fieldname;
|
$colnames[] = $fieldname;
|
||||||
$coltypes[] = $type;
|
$coltypes[] = $type;
|
||||||
$collengths[]= $length;
|
$collengths[]= $length;
|
||||||
|
}
|
||||||
|
|
||||||
echo "<br>--><b>processsing db field ".$fieldname.'</b>';
|
echo "<br>--><b>processsing db field ".$fieldname.'</b>';
|
||||||
echo "<br>---><b>method ".$method.'</b>';
|
echo "<br>---><b>method ".$method.'</b>';
|
||||||
|
@ -181,7 +185,7 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||||
|
|
||||||
echo "<br>Total number of recrods is ..".$totalrecords;
|
echo "<br>Total number of recrods is ..".$totalrecords;
|
||||||
|
|
||||||
while($counter < $totalrecords) { //while there is still something restore_create_logs()
|
while(($counter < $totalrecords) and ($fieldname !='dummy')) { //while there is still something
|
||||||
$SQL = 'SELECT * FROM '.$CFG->prefix.$dbtablename.' '.sql_paging_limit($counter, $recordsetsize);
|
$SQL = 'SELECT * FROM '.$CFG->prefix.$dbtablename.' '.sql_paging_limit($counter, $recordsetsize);
|
||||||
echo "<br> SQL: ".$SQL;
|
echo "<br> SQL: ".$SQL;
|
||||||
if ($records = get_records_sql($SQL)) {
|
if ($records = get_records_sql($SQL)) {
|
||||||
|
@ -232,11 +236,13 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||||
$newrecord = new object;
|
$newrecord = new object;
|
||||||
$newrecord->id = $record->id;
|
$newrecord->id = $record->id;
|
||||||
$newrecord->{$fieldname} = $result;
|
$newrecord->{$fieldname} = $result;
|
||||||
if ($dbtablename == "data_content"){
|
/*
|
||||||
|
if ($dbtablename == "user_teachers"){
|
||||||
echo "<br>here we go ".$record->{$fieldname};
|
echo "<br>here we go ".$record->{$fieldname};
|
||||||
echo "<br>after conversion".$result;
|
echo "<br>after conversion".$result;
|
||||||
|
echo "<br>conv lang is ".$fromenc;
|
||||||
print_object($newrecord);
|
print_object($newrecord);
|
||||||
}
|
}*/
|
||||||
update_record($dbtablename,$newrecord);
|
update_record($dbtablename,$newrecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,8 +278,11 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||||
} else {
|
} else {
|
||||||
//posgresql code here
|
//posgresql code here
|
||||||
}
|
}
|
||||||
|
|
||||||
//$db->debug=999;
|
//$db->debug=999;
|
||||||
|
if ($fieldname != 'dummy') {
|
||||||
execute_sql($SQL);
|
execute_sql($SQL);
|
||||||
|
}
|
||||||
//$db->debug=0;
|
//$db->debug=0;
|
||||||
|
|
||||||
//add index back
|
//add index back
|
||||||
|
@ -368,6 +377,7 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||||
$SQL = 'ALTER DATABASE '.$CFG->dbname.' CHARACTER SET utf8';
|
$SQL = 'ALTER DATABASE '.$CFG->dbname.' CHARACTER SET utf8';
|
||||||
execute_sql($SQL);
|
execute_sql($SQL);
|
||||||
delete_records('config','name','dbmigration'); //bye bye
|
delete_records('config','name','dbmigration'); //bye bye
|
||||||
|
//DROP CACHE FILEDS HERE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -379,6 +389,7 @@ function get_course_lang($courseid) {
|
||||||
if ($course = get_record('course','id',$courseid)){
|
if ($course = get_record('course','id',$courseid)){
|
||||||
return $course->lang;
|
return $course->lang;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns the teacher's lang
|
/* returns the teacher's lang
|
||||||
|
@ -427,6 +438,7 @@ function get_user_lang($userid) {
|
||||||
if ($user = get_record('user','id',$userid)){
|
if ($user = get_record('user','id',$userid)){
|
||||||
return $user->lang;
|
return $user->lang;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a placeholder for now
|
// a placeholder for now
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue