4th iteration committed: xmldb_field, xmldb_index and xmldb_key "public" methods...
authorstronk7 <stronk7>
Thu, 22 May 2008 00:09:59 +0000 (00:09 +0000)
committerstronk7 <stronk7>
Thu, 22 May 2008 00:09:59 +0000 (00:09 +0000)
12 files changed:
admin/xmldb/actions/test/test.class.php
admin/xmldb/actions/view_table_php/view_table_php.class.php
blocks/db/upgrade.php
lib/db/upgrade.php
lib/ddl/sql_generator.php
lib/xmldb/xmldb_field.php
lib/xmldb/xmldb_index.php
lib/xmldb/xmldb_key.php
lib/xmldb/xmldb_table.php
mod/data/db/upgrade.php
mod/feedback/db/upgrade.php
mod/lesson/db/upgrade.php

index 48acd38f191cb527e41c72980df4a58e584fc097..0705ad81660eef87c5c3c6421fe1669ae523a845 100644 (file)
@@ -175,8 +175,7 @@ class test extends XMLDBAction {
     /// 4th test. Adding one complex enum field
         if ($test->status) {
         /// Create a new field with complex specs (enums are good candidates)
-            $field = new xmldb_field('type');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
+            $field = new xmldb_field('type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
         /// Get SQL code and execute it
             $test = new stdClass;
             $test->sql = $gen->getAddFieldSQL($table, $field);
@@ -202,8 +201,7 @@ class test extends XMLDBAction {
     /// 6th test. Adding one complex enum field
         if ($test->status) {
         /// Create a new field with complex specs (enums are good candidates)
-            $field = new xmldb_field('type');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
+            $field = new xmldb_field('type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
         /// Get SQL code and execute it
             $test = new stdClass;
             $test->sql = $gen->getAddFieldSQL($table, $field);
@@ -217,8 +215,7 @@ class test extends XMLDBAction {
     /// 7th test. Adding one numeric field
         if ($test->status) {
         /// Create a new field (numeric)
-            $field = new xmldb_field('onenumber');
-            $field->setAttributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'type');
+            $field = new xmldb_field('onenumber', XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'type');
         /// Get SQL code and execute it
             $test = new stdClass;
             $test->sql = $gen->getAddFieldSQL($table, $field);
@@ -246,8 +243,7 @@ class test extends XMLDBAction {
         if ($test->status) {
         /// Get SQL code and execute it
             $test = new stdClass;
-            $field = new xmldb_field('course');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, '0');
+            $field = new xmldb_field('course', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, '0');
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_type($table, $field, false, false);
@@ -261,8 +257,7 @@ class test extends XMLDBAction {
         if ($test->status) {
         /// Get SQL code and execute it
             $test = new stdClass;
-            $field = new xmldb_field('course');
-            $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+            $field = new xmldb_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_type($table, $field, false, false);
@@ -276,8 +271,7 @@ class test extends XMLDBAction {
         if ($test->status) {
         /// Get SQL code and execute it
             $test = new stdClass;
-            $field = new xmldb_field('grade');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, "test'n drop");
+            $field = new xmldb_field('grade', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, "test'n drop");
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_type($table, $field, false, false);
@@ -291,8 +285,7 @@ class test extends XMLDBAction {
         if ($test->status) {
         /// Get SQL code and execute it
             $test = new stdClass;
-            $field = new xmldb_field('grade');
-            $field->setAttributes(XMLDB_TYPE_FLOAT, '20,10', XMLDB_UNSIGNED, null, null, null, null, null);
+            $field = new xmldb_field('grade', XMLDB_TYPE_FLOAT, '20,10', XMLDB_UNSIGNED, null, null, null, null, null);
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_type($table, $field, false, false);
@@ -306,8 +299,7 @@ class test extends XMLDBAction {
         if ($test->status) {
         /// Get SQL code and execute it
             $test = new stdClass;
-            $field = new xmldb_field('grade');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'test');
+            $field = new xmldb_field('grade', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'test');
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_type($table, $field, false, false);
@@ -321,8 +313,7 @@ class test extends XMLDBAction {
         if ($test->status) {
         /// Get SQL code and execute it
             $test = new stdClass;
-            $field = new xmldb_field('grade');
-            $field->setAttributes(XMLDB_TYPE_NUMBER, '20,10', XMLDB_UNSIGNED, null, null, null, null, null);
+            $field = new xmldb_field('grade', XMLDB_TYPE_NUMBER, '20,10', XMLDB_UNSIGNED, null, null, null, null, null);
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_type($table, $field, false, false);
@@ -338,7 +329,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('intro');
-            $field->setAttributes(XMLDB_TYPE_TEXT, 'big', null, XMLDB_NOTNULL, null, null, null, null);
+            $field->set_attributes(XMLDB_TYPE_TEXT, 'big', null, XMLDB_NOTNULL, null, null, null, null);
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_precision($table, $field, false, false);
@@ -353,7 +344,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('secondname');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null);
+            $field->set_attributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null);
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_precision($table, $field, false, false);
@@ -368,7 +359,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('grade');
-            $field->setAttributes(XMLDB_TYPE_NUMBER, '10,2', null, null, null, null, null, null);
+            $field->set_attributes(XMLDB_TYPE_NUMBER, '10,2', null, null, null, null, null, null);
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_precision($table, $field, false, false);
@@ -383,7 +374,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('course');
-            $field->setAttributes(XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+            $field->set_attributes(XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_precision($table, $field, false, false);
@@ -398,7 +389,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('grade');
-            $field->setAttributes(XMLDB_TYPE_NUMBER, '10,2', XMLDB_UNSIGNED, null, null, null, null, null);
+            $field->set_attributes(XMLDB_TYPE_NUMBER, '10,2', XMLDB_UNSIGNED, null, null, null, null, null);
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_unsigned($table, $field, false, false);
@@ -413,7 +404,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('grade');
-            $field->setAttributes(XMLDB_TYPE_NUMBER, '10,2', null, null, null, null, null, null);
+            $field->set_attributes(XMLDB_TYPE_NUMBER, '10,2', null, null, null, null, null, null);
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_unsigned($table, $field, false, false);
@@ -428,7 +419,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('name');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, 'Moodle');
+            $field->set_attributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, 'Moodle');
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_notnull($table, $field, false, false);
@@ -443,7 +434,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('name');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, 'Moodle');
+            $field->set_attributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, 'Moodle');
 
             $test->sql = $gen->getAlterFieldSQL($table, $field);
             $test->status = $dbman->change_field_notnull($table, $field, false, false);
@@ -458,7 +449,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('name');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, null);
+            $field->set_attributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, null);
 
             $test->sql = $gen->getModifyDefaultSQL($table, $field);
             $test->status = $dbman->change_field_default($table, $field, false, false);
@@ -473,7 +464,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('name');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, 'Moodle');
+            $field->set_attributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, 'Moodle');
 
             $test->sql = $gen->getModifyDefaultSQL($table, $field);
             $test->status = $dbman->change_field_default($table, $field, false, false);
@@ -488,7 +479,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('secondname');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'Moodle2');
+            $field->set_attributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'Moodle2');
 
             $test->sql = $gen->getModifyDefaultSQL($table, $field);
             $test->status = $dbman->change_field_default($table, $field, false, false);
@@ -504,7 +495,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('secondname');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null);
+            $field->set_attributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null);
 
             $test->sql = $gen->getModifyDefaultSQL($table, $field);
             $test->status = $dbman->change_field_default($table, $field, false, false);
@@ -519,7 +510,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $index = new xmldb_index('secondname');
-            $index->setAttributes(XMLDB_INDEX_UNIQUE, array('name', 'secondname', 'grade'));
+            $index->set_attributes(XMLDB_INDEX_UNIQUE, array('name', 'secondname', 'grade'));
 
             $test->sql = $gen->getAddIndexSQL($table, $index);
             $test->status = $dbman->add_index($table, $index, false, false);
@@ -534,7 +525,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $index = new xmldb_index('secondname');
-            $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course', 'name'));
+            $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('course', 'name'));
 
             $test->sql = $gen->getAddIndexSQL($table, $index);
             $test->status = $dbman->add_index($table, $index, false, false);
@@ -549,7 +540,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $index = new xmldb_index('secondname');
-            $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('name', 'course'));
+            $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('name', 'course'));
 
             if ($indexfound = $dbman->find_index_name($table, $index)) {
                 $test->status = true;
@@ -568,7 +559,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $index = new xmldb_index('name');
-            $index->setAttributes(XMLDB_INDEX_UNIQUE, array('name', 'grade', 'secondname'));
+            $index->set_attributes(XMLDB_INDEX_UNIQUE, array('name', 'grade', 'secondname'));
 
             $test->sql = $gen->getDropIndexSQL($table, $index);
             $test->status = $dbman->drop_index($table, $index, false, false);
@@ -583,7 +574,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $key = new xmldb_key('id-course-grade');
-            $key->setAttributes(XMLDB_KEY_UNIQUE, array('id', 'course', 'grade'));
+            $key->set_attributes(XMLDB_KEY_UNIQUE, array('id', 'course', 'grade'));
 
             $test->sql = $gen->getAddKeySQL($table, $key);
             $test->status = $dbman->add_key($table, $key, false, false);
@@ -598,7 +589,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $key = new xmldb_key('course');
-            $key->setAttributes(XMLDB_KEY_FOREIGN_UNIQUE, array('course'), 'anothertest', array('id'));
+            $key->set_attributes(XMLDB_KEY_FOREIGN_UNIQUE, array('course'), 'anothertest', array('id'));
 
             $test->sql = $gen->getAddKeySQL($table, $key);
             $test->status = $dbman->add_key($table, $key, false, false);
@@ -613,7 +604,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $key = new xmldb_key('course');
-            $key->setAttributes(XMLDB_KEY_FOREIGN_UNIQUE, array('course'), 'anothertest', array('id'));
+            $key->set_attributes(XMLDB_KEY_FOREIGN_UNIQUE, array('course'), 'anothertest', array('id'));
 
             $test->sql = $gen->getDropKeySQL($table, $key);
             $test->status = $dbman->drop_key($table, $key, false, false);
@@ -628,7 +619,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $key = new xmldb_key('course');
-            $key->setAttributes(XMLDB_KEY_FOREIGN, array('course'), 'anothertest', array('id'));
+            $key->set_attributes(XMLDB_KEY_FOREIGN, array('course'), 'anothertest', array('id'));
 
             $test->sql = $gen->getAddKeySQL($table, $key);
             $test->status = $dbman->add_key($table, $key, false, false);
@@ -643,7 +634,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $key = new xmldb_key('course');
-            $key->setAttributes(XMLDB_KEY_FOREIGN, array('course'), 'anothertest', array('id'));
+            $key->set_attributes(XMLDB_KEY_FOREIGN, array('course'), 'anothertest', array('id'));
 
             $test->sql = $gen->getDropKeySQL($table, $key);
             $test->status = $dbman->drop_key($table, $key, false, false);
@@ -657,7 +648,7 @@ class test extends XMLDBAction {
         if ($test->status) {
         /// Create a new field with complex specs (enums are good candidates)
             $field = new xmldb_field('type');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
+            $field->set_attributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
         /// Get SQL code and execute it
             $test = new stdClass;
             $test->sql = $gen->getAddFieldSQL($table, $field);
@@ -674,7 +665,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('type');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'general', 'course');
+            $field->set_attributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'general', 'course');
             $test->sql = $gen->getModifyEnumSQL($table, $field);
             $test->status = $dbman->change_field_enum($table, $field, false, false);
             if (!$test->status) {
@@ -688,7 +679,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('type');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
+            $field->set_attributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
             $test->sql = $gen->getModifyEnumSQL($table, $field);
             $test->status = $dbman->change_field_enum($table, $field, false, false);
             if (!$test->status) {
@@ -702,7 +693,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $index = new xmldb_index('anyname');
-            $index->setAttributes(XMLDB_INDEX_UNIQUE, array('name', 'course'));
+            $index->set_attributes(XMLDB_INDEX_UNIQUE, array('name', 'course'));
             $test->sql = $gen->getRenameIndexSQL($table, $index, 'newnamefortheindex');
             $test->status = $dbman->rename_index($table, $index, 'newnamefortheindex', false, false);
             if (!$test->status) {
@@ -718,7 +709,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $key = new xmldb_key('anyname');
-            $key->setAttributes(XMLDB_KEY_UNIQUE, array('id', 'course', 'grade'));
+            $key->set_attributes(XMLDB_KEY_UNIQUE, array('id', 'course', 'grade'));
 
             $test->sql = $gen->getRenameKeySQL($table, $key, 'newnameforthekey', true);
             $olddebug = $CFG->debug;
@@ -740,7 +731,7 @@ class test extends XMLDBAction {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new xmldb_field('type');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
+            $field->set_attributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
 
             $test->sql = $gen->getRenameFieldSQL($table, $field, 'newnameforthefield', true);
             $test->status = $dbman->rename_field($table, $field, 'newnameforthefield', false, false);
@@ -768,7 +759,7 @@ class test extends XMLDBAction {
         /// Add enum to field containing enum
             $table->setName('newnameforthetable');
             $field = new xmldb_field('newnameforthefield');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
+            $field->set_attributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
         /// Get SQL code and execute it
             $test = new stdClass;
             $test->sql = $gen->getModifyEnumSQL($table, $field);
@@ -790,7 +781,7 @@ class test extends XMLDBAction {
         /// Drop enum from field containing enum
             $table->setName('newnameforthetable');
             $field = new xmldb_field('newnameforthefield');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'general', 'course');
+            $field->set_attributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'general', 'course');
         /// Get SQL code and execute it
             $test = new stdClass;
             $test->sql = $gen->getModifyEnumSQL($table, $field);
@@ -806,7 +797,7 @@ class test extends XMLDBAction {
         /// Drop enum from field not containing enum
             $table->setName('newnameforthetable');
             $field = new xmldb_field('newnameforthefield');
-            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'general', 'course');
+            $field->set_attributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'general', 'course');
         /// Get SQL code and execute it
             $test = new stdClass;
             $test->sql = $gen->getModifyEnumSQL($table, $field);
index 3725961d5a994209948ece3e5e0e7cdb6faf93ab..f356579fab8dd34fb27df095c80878708e78cf12 100644 (file)
@@ -331,8 +331,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Define field ' . $field->getName() . ' to be added to ' . $table->getName() . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field->setAttributes(' . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -424,8 +423,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Rename field ' . $field->getName() . ' on table ' . $table->getName() . ' to NEWNAMEGOESHERE'. XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field->setAttributes(' . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -480,8 +478,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Changing type of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $type . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field->setAttributes(' . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -533,8 +530,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Changing precision of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $precision . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field->setAttributes(' . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "', " .$field->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -582,8 +578,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Changing sign of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $unsigned . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field->setAttributes(' . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -631,8 +626,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Changing nullability of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $notnull . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field->setAttributes(' . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -681,8 +675,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Changing list of values (enum) of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $enum . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field->setAttributes(' . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -730,8 +723,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Changing the default of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $default . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $field->setAttributes(' . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -777,8 +769,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Define key ' . $key->getName() . ' ('. $key->getXMLDBKeyName($key->getType()) . ') to be added to ' . $table->getName() . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $key = new xmldb_key(' . "'" . $key->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $key->setAttributes(' . $key->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $key = new xmldb_key(' . "'" . $key->getName() . "', " . $key->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -824,8 +815,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Define key ' . $key->getName() . ' ('. $key->getXMLDBKeyName($key->getType()) . ') to be dropped form ' . $table->getName() . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $key = new xmldb_key(' . "'" . $key->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $key->setAttributes(' . $key->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $key = new xmldb_key(' . "'" . $key->getName() . "', " . $key->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -874,8 +864,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Define key ' . $key->getName() . ' ('. $key->getXMLDBKeyName($key->getType()) . ') to be renamed to NEWNAMEGOESHERE' . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $key = new xmldb_key(' . "'" . $key->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $key->setAttributes(' . $key->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $key = new xmldb_key(' . "'" . $key->getName() . "', " . $key->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -921,8 +910,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Define index ' . $index->getName() . ' ('. ($index->getUnique() ? 'unique' : 'not unique') . ') to be added to ' . $table->getName() . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $index = new xmldb_index(' . "'" . $index->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $index->setAttributes(' . $index->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $index = new xmldb_index(' . "'" . $index->getName() . "', " . $index->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -968,8 +956,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Define index ' . $index->getName() . ' ('. ($index->getUnique() ? 'unique' : 'not unique') . ') to be dropped form ' . $table->getName() . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $index = new xmldb_index(' . "'" . $index->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $index->setAttributes(' . $index->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $index = new xmldb_index(' . "'" . $index->getName() . "', " . $index->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
@@ -1018,8 +1005,7 @@ class view_table_php extends XMLDBAction {
         $result .= XMLDB_LINEFEED;
         $result .= '    /// Define index ' . $index->getName() . ' ('. ($index->getUnique() ? 'unique' : 'not unique') . ') to be renamed to NEWNAMEGOESHERE' . XMLDB_LINEFEED;
         $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $index = new xmldb_index(' . "'" . $index->getName() . "'" . ');' . XMLDB_LINEFEED;
-        $result .= '        $index->setAttributes(' . $index->getPHP(true) . ');' . XMLDB_LINEFEED;
+        $result .= '        $index = new xmldb_index(' . "'" . $index->getName() . "', " . $index->getPHP(true) . ');' . XMLDB_LINEFEED;
 
     /// Launch the proper DDL
         $result .= XMLDB_LINEFEED;
index f49995ee68c930e084d9a4a9e3a49eb7a69d3d14..636f73986858b5d83628b311a0dc196c1f258b6c 100644 (file)
@@ -37,7 +37,7 @@ function xmldb_blocks_upgrade($oldversion=0) {
     /// Changing nullability of field configdata on table block_instance to null
         $table = new xmldb_table('block_instance');
         $field = new xmldb_field('configdata');
-        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'visible');
+        $field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'visible');
 
     /// Launch change of nullability for field configdata
         $result = $result && change_field_notnull($table, $field);
index 4472450589736f19a904be7912e60b2f65c8d784..cc1e6cd07c25111691b041bf836f35ef573411c2 100644 (file)
@@ -33,16 +33,14 @@ function xmldb_main_upgrade($oldversion=0) {
 
     /// Define index contextid-lowerboundary (not unique) to be dropped form grade_letters
         $table = new xmldb_table('grade_letters');
-        $index = new xmldb_index('contextid-lowerboundary');
-        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
+        $index = new xmldb_index('contextid-lowerboundary', XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
 
     /// Launch drop index contextid-lowerboundary
         $result = $result && $dbman->drop_index($table, $index);
 
     /// Define index contextid-lowerboundary-letter (unique) to be added to grade_letters
         $table = new xmldb_table('grade_letters');
-        $index = new xmldb_index('contextid-lowerboundary-letter');
-        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('contextid', 'lowerboundary', 'letter'));
+        $index = new xmldb_index('contextid-lowerboundary-letter', XMLDB_INDEX_UNIQUE, array('contextid', 'lowerboundary', 'letter'));
 
     /// Launch add index contextid-lowerboundary-letter
         $result = $result && $dbman->add_index($table, $index);
@@ -96,8 +94,7 @@ function xmldb_main_upgrade($oldversion=0) {
 
     /// Define index idnumber (not unique) to be dropped form user
         $table = new xmldb_table('user');
-        $index = new xmldb_index('idnumber');
-        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
+        $index = new xmldb_index('idnumber', XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
 
     /// Launch drop index idnumber
         if ($dbman->index_exists($table, $index)) {
@@ -106,15 +103,13 @@ function xmldb_main_upgrade($oldversion=0) {
 
     /// Changing precision of field idnumber on table user to (255)
         $table = new xmldb_table('user');
-        $field = new xmldb_field('idnumber');
-        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'password');
+        $field = new xmldb_field('idnumber', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'password');
 
     /// Launch change of precision for field idnumber
         $result = $result && $dbman->change_field_precision($table, $field);
 
     /// Launch add index idnumber again
-        $index = new xmldb_index('idnumber');
-        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
+        $index = new xmldb_index('idnumber', XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
         $result = $result && $dbman->add_index($table, $index);
 
     /// Main savepoint reached
index 3ce38c11fb5e20fd8a819ac75d89dc425e9d6f1f..67b2ef29f397514a356a4a915e1716ee39a5d7f7 100644 (file)
@@ -754,8 +754,7 @@ abstract class sql_generator {
             } else {
                 $indextype = XMLDB_INDEX_UNIQUE;
             }
-            $xmldb_index = new xmldb_index('anyname');
-            $xmldb_index->setAttributes($indextype, $xmldb_key->getFields());
+            $xmldb_index = new xmldb_index('anyname', $indextype, $xmldb_key->getFields());
             if (!$this->mdb->get_manager()->index_exists($xmldb_table, $xmldb_index)) {
                 $results = array_merge($results, $this->getAddIndexSQL($xmldb_table, $xmldb_index));
             }
@@ -822,8 +821,7 @@ abstract class sql_generator {
     /// automatically by the RDBMS) drop the underlying (created by us) index (if exists)
         if (!$dropkey || $xmldb_key->getType() == XMLDB_KEY_FOREIGN) {
         /// Only if they exist
-            $xmldb_index = new xmldb_index('anyname');
-            $xmldb_index->setAttributes(XMLDB_INDEX_UNIQUE, $xmldb_key->getFields());
+            $xmldb_index = new xmldb_index('anyname', XMLDB_INDEX_UNIQUE, $xmldb_key->getFields());
             if ($this->mdb->get_manager()->index_exists($xmldb_table, $xmldb_index)) {
                 $results = array_merge($results, $this->getDropIndexSQL($xmldb_table, $xmldb_index));
             }
index bc57f58df73ad3a0e310c0791c10185833e6079d..001f0e9a1014e844a30d69201450b294c6be4678 100644 (file)
@@ -52,8 +52,7 @@ class xmldb_field extends xmldb_object {
     /**
      * Creates one new xmldb_field
      */
-    function __construct($name) {
-        parent::__construct($name);
+    function __construct($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
         $this->type = NULL;
         $this->length = NULL;
         $this->unsigned = true;
@@ -63,7 +62,20 @@ class xmldb_field extends xmldb_object {
         $this->enum = false;
         $this->enumvalues = NULL;
         $this->decimals = NULL;
+        parent::__construct($name);
+        $this->set_attributes($type, $precision, $unsigned, $notnull, $sequence, $enum, $enumvalues, $default, $previous);
+    }
+
+/// TODO: Delete for 2.1 (deprecated in 2.0).
+/// Deprecated API starts here
+
+    function setAttributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
+
+        debugging('XMLDBField->setAttributes() has been deprecated in Moodle 2.0. Will be out in Moodle 2.1. Please use xmldb_field->set_attributes() instead.', DEBUG_DEVELOPER);
+
+        return $this->set_attributes($type, $precision, $unsigned, $notnull, $sequence, $enum, $enumvalues, $default, $previous);
     }
+/// Deprecated API ends here
 
     /**
      * Set all the attributes of one xmldb_field
@@ -77,7 +89,7 @@ class xmldb_field extends xmldb_object {
      * @param array enumvalues an array of possible values if XMLDB_ENUM is set
      * @param string default meaningful default o null (or false)
      */
-    function setAttributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
+    function set_attributes($type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
         $this->type = $type;
     /// Try to split the precision into length and decimals and apply
     /// each one as needed
index 0c1577f66eda155691cc15ff5741d177bdecea0f..dcfb0aaee23ab1490a4e9bd7a8c0598db70020b5 100644 (file)
@@ -45,19 +45,30 @@ class xmldb_index extends xmldb_object {
     /**
      * Creates one new xmldb_index
      */
-    function __construct($name) {
-        parent::__construct($name);
+    function __construct($name, $type=null, $fields=null) {
         $this->unique = false;
         $this->fields = array();
+        parent::__construct($name);
+        return $this->set_attributes($type, $fields);
     }
 
+/// TODO: Delete for 2.1 (deprecated in 2.0).
+/// Deprecated API starts here
+    function setAttributes($type, $fields) {
+
+        debugging('XMLDBIndex->setAttributes() has been deprecated in Moodle 2.0. Will be out in Moodle 2.1. Please use xmldb_index->set_attributes() instead.', DEBUG_DEVELOPER);
+
+        return $this->set_attributes($type, $fields);
+    }
+/// Deprecated API ends here
+
     /**
      * Set all the attributes of one xmldb_index
      *
      * @param string type XMLDB_INDEX_UNIQUE, XMLDB_INDEX_NOTUNIQUE
      * @param array fields an array of fieldnames to build the index over
      */
-    function setAttributes($type, $fields) {
+    function set_attributes($type, $fields) {
         $this->unique = !empty($type) ? true : false;
         $this->fields = $fields;
     }
index 00a5ca939d4d8291b681d04d9f34b29bd93f0768..fb60c0c4db0c6f1804c1af8e7048b7dd6a6652ea 100644 (file)
@@ -47,14 +47,26 @@ class xmldb_key extends xmldb_object {
     /**
      * Creates one new xmldb_key
      */
-    function __construct($name) {
-        parent::__construct($name);
+    function __construct($name, $type=null, $fields=null, $reftable=null, $reffields=null) {
         $this->type = NULL;
         $this->fields = array();
         $this->reftable = NULL;
         $this->reffields = array();
+        parent::__construct($name);
+        $this->set_attributes($type, $fields, $reftable, $reffields);
     }
 
+/// TODO: Delete for 2.1 (deprecated in 2.0).
+/// Deprecated API starts here
+
+    function setAttributes($type, $fields, $reftable=null, $reffields=null) {
+
+        debugging('XMLDBKey->setAttributes() has been deprecated in Moodle 2.0. Will be out in Moodle 2.1. Please use xmldb_key->set_attributes() instead.', DEBUG_DEVELOPER);
+
+        return $this->set_attributes($type, $fields, $reftable, $reffields);
+    }
+/// Deprecated API ends here
+
     /**
      * Set all the attributes of one xmldb_key
      *
@@ -63,11 +75,11 @@ class xmldb_key extends xmldb_object {
      * @param string reftable name of the table the FK points to or null
      * @param array reffields an array of fieldnames in the FK table or null
      */
-    function setAttributes($type, $fields, $reftable=null, $reffields=null) {
+    function set_attributes($type, $fields, $reftable=null, $reffields=null) {
         $this->type = $type;
         $this->fields = $fields;
         $this->reftable = $reftable;
-        $this->reffields = $reffields;
+        $this->reffields = empty($reffields) ? array() : $reffields;
     }
 
     /**
index 673fcc5bf18159cf2904a0341e17628092b70178..d4fdfc2bcbeb44450c3204d97c68e57b0bedf403 100644 (file)
@@ -733,8 +733,7 @@ class xmldb_table extends xmldb_object {
      * @param string previous name of the previous field in the table or null (or false)
      */
     function add_field($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
-        $field = new xmldb_field($name);
-        $field->setAttributes($type, $precision, $unsigned, $notnull, $sequence, $enum, $enumvalues, $default);
+        $field = new xmldb_field($name, $type, $precision, $unsigned, $notnull, $sequence, $enum, $enumvalues, $default);
         $this->addField($field, $previous);
 
         return $field;
@@ -763,8 +762,7 @@ class xmldb_table extends xmldb_object {
      * @param array reffields an array of fieldnames in the FK table or null
      */
     function add_key($name, $type, $fields, $reftable=null, $reffields=null) {
-        $key = new xmldb_key($name);
-        $key->setAttributes($type, $fields, $reftable, $reffields);
+        $key = new xmldb_key($name, $type, $fields, $reftable, $reffields);
         $this->addKey($key);
     }
 
@@ -788,8 +786,7 @@ class xmldb_table extends xmldb_object {
      * @param array fields an array of fieldnames to build the index over
      */
     function add_index($name, $type, $fields) {
-        $index = new xmldb_index($name);
-        $index->setAttributes($type, $fields);
+        $index = new xmldb_index($name, $type, $fields);
         $this->addIndex($index);
     }
 
index f6f5b66aefd4040e57b23161bcac988bb593eecc..af524e3e87e19fa109b4127029caed6892cf1977 100644 (file)
@@ -31,8 +31,7 @@ function xmldb_data_upgrade($oldversion=0) {
     /// Launch add field asearchtemplate again if does not exists yet - reported on several sites
 
         $table = new xmldb_table('data');
-        $field = new xmldb_field('asearchtemplate');
-        $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'jstemplate');
+        $field = new xmldb_field('asearchtemplate', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'jstemplate');
 
         if (!$dbman->field_exists($table, $field)) {
             $result = $result && $dbman->add_field($table, $field);
@@ -46,9 +45,8 @@ function xmldb_data_upgrade($oldversion=0) {
         $result = $DB->execute($sql);
 
         $table = new xmldb_table('data');
-        $field = new xmldb_field('notification');
+        $field = new xmldb_field('notification', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'editany');
         // First step, Set NOT NULL
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'editany');
         $result = $result && $dbman->change_field_notnull($table, $field);
         // Second step, Set default to 0
         $result = $result && $dbman->change_field_default($table, $field);
index cddad37de8cf3fdab1dfa6380747a287f01a5627..5fce1ee69b6565f6a705189d8a55e9d3cbdb9912 100644 (file)
@@ -31,31 +31,31 @@ function xmldb_feedback_upgrade($oldversion=0) {
         $table = new xmldb_table('feedback_completedtmp');
 
         $field = new xmldb_field('id');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null, null, null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null, null, null);
         $table->addField($field);
         
         $field = new xmldb_field('feedback');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
         $table->addField($field);
         
         $field = new xmldb_field('userid');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
         $table->addField($field);
 
         $field = new xmldb_field('guestid');
-        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, null, false, null, null, '', null);
+        $field->set_attributes(XMLDB_TYPE_CHAR, '255', null, null, false, null, null, '', null);
         $table->addField($field);
 
         $field = new xmldb_field('timemodified');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
         $table->addField($field);
         
         $key = new xmldb_key('PRIMARY');
-        $key->setAttributes(XMLDB_KEY_PRIMARY, array('id'));
+        $key->set_attributes(XMLDB_KEY_PRIMARY, array('id'));
         $table->addKey($key);
         
         $key = new xmldb_key('feedback');
-        $key->setAttributes(XMLDB_KEY_FOREIGN, array('feedback'), 'feedback', 'id');
+        $key->set_attributes(XMLDB_KEY_FOREIGN, array('feedback'), 'feedback', 'id');
         $table->addKey($key);
 
         $result = $result && $dbman->create_table($table);
@@ -65,35 +65,35 @@ function xmldb_feedback_upgrade($oldversion=0) {
         $table = new xmldb_table('feedback_valuetmp');
 
         $field = new xmldb_field('id');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null, null, null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null, null, null);
         $table->addField($field);
         
         $field = new xmldb_field('course_id');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
         $table->addField($field);
         
         $field = new xmldb_field('item');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
         $table->addField($field);
         
         $field = new xmldb_field('completed');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
         $table->addField($field);
         
         $field = new xmldb_field('tmp_completed');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
         $table->addField($field);
 
         $field = new xmldb_field('value');
-        $field->setAttributes(XMLDB_TYPE_TEXT, null, null, null, false, null, null, '', null);
+        $field->set_attributes(XMLDB_TYPE_TEXT, null, null, null, false, null, null, '', null);
         $table->addField($field);
         
         $key = new xmldb_key('PRIMARY');
-        $key->setAttributes(XMLDB_KEY_PRIMARY, array('id'));
+        $key->set_attributes(XMLDB_KEY_PRIMARY, array('id'));
         $table->addKey($key);
         
         $key = new xmldb_key('feedback');
-        $key->setAttributes(XMLDB_KEY_FOREIGN, array('item'), 'feedback_item', 'id');
+        $key->set_attributes(XMLDB_KEY_FOREIGN, array('item'), 'feedback_item', 'id');
         $table->addKey($key);
 
         $result = $result && $dbman->create_table($table);
@@ -104,29 +104,25 @@ function xmldb_feedback_upgrade($oldversion=0) {
 
         /// Define field random_response to be added to feedback_completed
         $table = new xmldb_table('feedback_completed');
-        $field = new xmldb_field('random_response');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
+        $field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
         /// Launch add field1
         $result = $result && $dbman->add_field($table, $field);
 
         /// Define field anonymous_response to be added to feedback_completed
         $table = new xmldb_table('feedback_completed');
-        $field = new xmldb_field('anonymous_response');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '1', null);
+        $field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '1', null);
         /// Launch add field2
         $result = $result && $dbman->add_field($table, $field);
 
         /// Define field random_response to be added to feedback_completed
         $table = new xmldb_table('feedback_completedtmp');
-        $field = new xmldb_field('random_response');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
+        $field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
         /// Launch add field1
         $result = $result && $dbman->add_field($table, $field);
 
         /// Define field anonymous_response to be added to feedback_completed
         $table = new xmldb_table('feedback_completedtmp');
-        $field = new xmldb_field('anonymous_response');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '1', null);
+        $field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '1', null);
         /// Launch add field2
         $result = $result && $dbman->add_field($table, $field);
 
@@ -137,8 +133,7 @@ function xmldb_feedback_upgrade($oldversion=0) {
         // public is a reserved word on Oracle
 
         $table = new xmldb_table('feedback_template');
-        $field = new xmldb_field('ispublic');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '1', null);
+        $field = new xmldb_field('ispublic', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '1', null);
         if (!$dbman->field_exists($table, $field)) {
             $result = $result && $dbman->add_field($table, $field);
         }
@@ -205,8 +200,7 @@ function xmldb_feedback_upgrade($oldversion=0) {
     if ($result && $oldversion < 2008042900) {
         /// Define field autonumbering to be added to feedback
         $table = new xmldb_table('feedback');
-        $field = new xmldb_field('autonumbering');
-        $field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1', 'multiple_submit');
+        $field = new xmldb_field('autonumbering', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1', 'multiple_submit');
         /// Launch add field2
         $result = $result && $dbman->add_field($table, $field);
     }
@@ -214,8 +208,7 @@ function xmldb_feedback_upgrade($oldversion=0) {
     if ($result && $oldversion < 2008050104) {
         /// Define field site_after_submit to be added to feedback
         $table = new xmldb_table('feedback');
-        $field = new xmldb_field('site_after_submit');
-        $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, null, false, null, null, '', 'autonumbering');
+        $field = new xmldb_field('site_after_submit', XMLDB_TYPE_CHAR, '255', null, null, false, null, null, '', 'autonumbering');
         /// Launch add field2
         $result = $result && $dbman->add_field($table, $field);
     }
index d98f3a8b2ec4da3afa30487d35fb2c4f137ba609..92cbc0a2c92d115fb89195aefae4307a97e565de 100644 (file)
@@ -36,7 +36,7 @@ function xmldb_lesson_upgrade($oldversion=0) {
     /// Rename lesson->usegrademax to lesson->usemaxgrade. Some old sites can have it incorrect. MDL-13177
         if ($dbman->field_exists($table, $field) && !$dbman->field_exists($table, $field2)) {
         /// Set field specs
-            $field->setAttributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, null, null, '0', 'ongoing');
+            $field->set_attributes(XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, null, null, '0', 'ongoing');
         /// Launch rename field usegrademax to usemaxgrade
             $result = $result && $dbman->rename_field($table, $field, 'usemaxgrade');
         }