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