/// automatically by the RDBMS) create the underlying (created by us) index (if doesn't exists)
if (!$dbman->generator->getKeySQL($xmldb_table, $xmldb_key) || $xmldb_key->getType() == XMLDB_KEY_FOREIGN) {
/// Create the interim index
- $xmldb_index = new XMLDBIndex('anyname');
+ $xmldb_index = new xmldb_index('anyname');
$xmldb_index->setFields($xmldb_key->getFields());
switch ($xmldb_key->getType()) {
case XMLDB_KEY_UNIQUE:
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
}
/// XMLDB field comment
$o.= ' <tr valign="top"><td><label for="comment" accesskey="c">Comment:</label></td><td colspan="2"><textarea name="comment" rows="3" cols="80" id="comment">' . s($field->getComment()) . '</textarea></td></tr>';
- /// XMLDBField Type
+ /// xmldb_field Type
$typeoptions = array (XMLDB_TYPE_INTEGER => $field->getXMLDBTypeName(XMLDB_TYPE_INTEGER),
XMLDB_TYPE_NUMBER => $field->getXMLDBTypeName(XMLDB_TYPE_NUMBER),
XMLDB_TYPE_FLOAT => $field->getXMLDBTypeName(XMLDB_TYPE_FLOAT),
}
$o.= ' <tr valign="top"><td><label for="menutype" accesskey="t">Type:</label></td>';
$o.= ' <td colspan="2">' . choose_from_menu($typeoptions, 'type', $field->getType(), '', '', '', true) . '</td></tr>';
- /// XMLDBField Length
+ /// xmldb_field Length
$o.= ' <tr valign="top"><td><label for="length" accesskey="l">Length:</label></td>';
$o.= ' <td colspan="2"><input name="length" type="text" size="6" maxlength="6" id="length" value="' . s($field->getLength()) . '" /><span id="lengthtip"></span></td></tr>';
- /// XMLDBField Decimals
+ /// xmldb_field Decimals
$o.= ' <tr valign="top"><td><label for="decimals" accesskey="d">Decimals:</label></td>';
$o.= ' <td colspan="2"><input name="decimals" type="text" size="6" maxlength="6" id="decimals" value="' . s($field->getDecimals()) . '" /><span id="decimalstip"></span></td></tr>';
- /// XMLDBField Unsigned
+ /// xmldb_field Unsigned
$unsignedoptions = array (0 => 'signed', 1 => 'unsigned');
$o.= ' <tr valign="top"><td><label for="menuunsigned" accesskey="u">Unsigned:</label></td>';
$o.= ' <td colspan="2">' . choose_from_menu($unsignedoptions, 'unsigned', $field->getUnsigned(), '', '', '', true) . '</td></tr>';
- /// XMLDBField NotNull
+ /// xmldb_field NotNull
$notnulloptions = array (0 => 'null', 'not null');
$o.= ' <tr valign="top"><td><label for="menunotnull" accesskey="n">Not Null:</label></td>';
$o.= ' <td colspan="2">' . choose_from_menu($notnulloptions, 'notnull', $field->getNotNull(), '', '', '', true) . '</td></tr>';
- /// XMLDBField Sequence
+ /// xmldb_field Sequence
$sequenceoptions = array (0 => $this->str['no'], 1 => 'auto-numbered');
$o.= ' <tr valign="top"><td><label for="menusequence" accesskey="s">Sequence:</label></td>';
$o.= ' <td colspan="2">' . choose_from_menu($sequenceoptions, 'sequence', $field->getSequence(), '', '', '', true) . '</td></tr>';
- /// XMLDBField Enum and enumvalues
+ /// xmldb_field Enum and enumvalues
$enumoptions = array (0 => $this->str['no'], 1 => $this->str['yes']);
$o.= ' <tr valign="top"><td><label for="menuenum" accesskey="s">Enum:</label></td>';
$o.= ' <td>' . choose_from_menu($enumoptions, 'enum', $field->getEnum(), '', '', '', true) . '</td>';
$enumvalues = '';
}
$o.= ' <td><textarea name="enumvalues" rows="3" cols="70" id="enumvalues">' . s($enumvalues) . '</textarea></td></tr>';
- /// XMLDBField Default
+ /// xmldb_field Default
$o.= ' <tr valign="top"><td><label for="default" accesskey="d">Default:</label></td>';
$o.= ' <td colspan="2"><input type="text" name="default" size="30" maxlength="80" id="default" value="' . s($field->getDefault()) . '" /></td></tr>';
/// Change button
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
}
if (!empty($errors)) {
- $tempfield = new XMLDBField($name);
+ $tempfield = new xmldb_field($name);
$tempfield->setType($type);
$tempfield->setLength($length);
$tempfield->setDecimals($decimals);
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
$o.= ' <tr valign="top"><td><label for="name" accesskey="n">Name:</label></td><td colspan="2"><input name="name" type="text" size="30" id="name"' . $disabled . ' value="' . s($index->getName()) . '" /></td></tr>';
/// XMLDB key comment
$o.= ' <tr valign="top"><td><label for="comment" accesskey="c">Comment:</label></td><td colspan="2"><textarea name="comment" rows="3" cols="80" id="comment">' . s($index->getComment()) . '</textarea></td></tr>';
- /// XMLDBIndex Type
+ /// xmldb_index Type
$typeoptions = array (0 => 'not unique',
1 => 'unique');
$o.= ' <tr valign="top"><td><label for="menuunique" accesskey="t">Type:</label></td>';
$o.= ' <td colspan="2">' . choose_from_menu($typeoptions, 'unique', $index->getUnique(), '', '', '', true) . '</td></tr>';
- /// XMLDBIndex Fields
+ /// xmldb_index Fields
$o.= ' <tr valign="top"><td><label for="fields" accesskey="f">Fields:</label></td>';
$o.= ' <td colspan="2"><input name="fields" type="text" size="40" maxlength="80" id="fields" value="' . s(implode(', ', $index->getFields())) . '" /></td></tr>';
/// Change button
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
}
if (!empty($errors)) {
- $tempindex = new XMLDBIndex($name);
+ $tempindex = new xmldb_index($name);
$tempindex->setUnique($unique);
$tempindex->setFields($fieldsarr);
/// Prepare the output
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
$o.= ' <tr valign="top"><td><label for="name" accesskey="n">Name:</label></td><td colspan="2"><input name="name" type="text" size="30" id="name"' . $disabled . ' value="' . s($key->getName()) . '" /></td></tr>';
/// XMLDB key comment
$o.= ' <tr valign="top"><td><label for="comment" accesskey="c">Comment:</label></td><td colspan="2"><textarea name="comment" rows="3" cols="80" id="comment">' . s($key->getComment()) . '</textarea></td></tr>';
- /// XMLDBKey Type
+ /// xmldb_key Type
$typeoptions = array (XMLDB_KEY_PRIMARY => $key->getXMLDBKeyName(XMLDB_KEY_PRIMARY),
XMLDB_KEY_UNIQUE => $key->getXMLDBKeyName(XMLDB_KEY_UNIQUE),
XMLDB_KEY_FOREIGN => $key->getXMLDBKeyName(XMLDB_KEY_FOREIGN),
/// }
$o.= ' <tr valign="top"><td><label for="menutype" accesskey="t">Type:</label></td>';
$o.= ' <td colspan="2">' . choose_from_menu($typeoptions, 'type', $key->getType(), '', '', '', true) . '</td></tr>';
- /// XMLDBKey Fields
+ /// xmldb_key Fields
$o.= ' <tr valign="top"><td><label for="fields" accesskey="f">Fields:</label></td>';
$o.= ' <td colspan="2"><input name="fields" type="text" size="40" maxlength="80" id="fields" value="' . s(implode(', ', $key->getFields())) . '" /></td></tr>';
- /// XMLDBKey Reftable
+ /// xmldb_key Reftable
$o.= ' <tr valign="top"><td><label for="reftable" accesskey="t">Reftable:</label></td>';
$o.= ' <td colspan="2"><input name="reftable" type="text" size="20" maxlength="40" id="reftable" value="' . s($key->getReftable()) . '" /></td></tr>';
- /// XMLDBKey Reffields
+ /// xmldb_key Reffields
$o.= ' <tr valign="top"><td><label for="reffields" accesskey="t">Reffields:</label></td>';
$o.= ' <td colspan="2"><input name="reffields" type="text" size="40" maxlength="80" id="reffields" value="' . s(implode(', ', $key->getRefFields())) . '" /></td></tr>';
/// Change button
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
if (!empty($errors)) {
- $tempkey = new XMLDBKey($name);
+ $tempkey = new xmldb_key($name);
$tempkey->setType($type);
$tempkey->setFields($fieldsarr);
if ($type == XMLDB_KEY_FOREIGN ||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
if (!$statementparam) {
$typeparam = optional_param('type', NULL, PARAM_CLEAN);
$tableparam = optional_param('table', NULL, PARAM_CLEAN);
- $typename = XMLDBStatement::getXMLDBStatementName($typeparam);
+ $typename = xmldb_statement::getXMLDBStatementName($typeparam);
$statementparam = trim(strtolower($typename . ' ' . $tableparam));
}
if (!$statement =& $structure->getStatement($statementparam)) {
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
}
if (!empty($errors)) {
- $temptable = new XMLDBTable($name);
+ $temptable = new xmldb_table($name);
/// Prepare the output
$site = get_site();
$navlinks = array();
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
}
}
if (!$changeme_exists) { /// Lets create the field
- $field = new XMLDBField('changeme');
+ $field = new xmldb_field('changeme');
$table->addField($field);
/// We have one new field, so the structure has changed
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
}
}
if (!$changeme_exists) { /// Lets create the Index
- $index = new XMLDBIndex('changeme');
+ $index = new xmldb_index('changeme');
$table->addIndex($index);
/// We have one new key, so the structure has changed
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
}
}
if (!$changeme_exists) { /// Lets create the Key
- $key = new XMLDBKey('changeme');
+ $key = new xmldb_key('changeme');
$table->addKey($key);
/// We have one new key, so the structure has changed
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
/// Get list of tables
$selecttables = $DB->get_tables();
/// Get list of statement types
- $typeoptions = array (XMLDB_STATEMENT_INSERT => XMLDBStatement::getXMLDBStatementName(XMLDB_STATEMENT_INSERT),
- XMLDB_STATEMENT_UPDATE => XMLDBStatement::getXMLDBStatementName(XMLDB_STATEMENT_UPDATE),
- XMLDB_STATEMENT_DELETE => XMLDBStatement::getXMLDBStatementName(XMLDB_STATEMENT_DELETE),
- XMLDB_STATEMENT_CUSTOM => XMLDBStatement::getXMLDBStatementName(XMLDB_STATEMENT_CUSTOM));
+ $typeoptions = array (XMLDB_STATEMENT_INSERT => xmldb_statement::getXMLDBStatementName(XMLDB_STATEMENT_INSERT),
+ XMLDB_STATEMENT_UPDATE => xmldb_statement::getXMLDBStatementName(XMLDB_STATEMENT_UPDATE),
+ XMLDB_STATEMENT_DELETE => xmldb_statement::getXMLDBStatementName(XMLDB_STATEMENT_DELETE),
+ XMLDB_STATEMENT_CUSTOM => xmldb_statement::getXMLDBStatementName(XMLDB_STATEMENT_CUSTOM));
if (!$selecttables) {
$this->errormsg = 'No tables available to create statements';
return false;
}
/// Calculate the name of the statement
- $typename = XMLDBStatement::getXMLDBStatementName($typeparam);
+ $typename = xmldb_statement::getXMLDBStatementName($typeparam);
$name = trim(strtolower($typename . ' ' . $tableparam));
/// Check that this Statement hasn't been created before
return false;
}
- /// Create one new XMLDBStatement
- $statement = new XMLDBStatement($name);
+ /// Create one new xmldb_statement
+ $statement = new xmldb_statement($name);
$statement->setType($typeparam);
$statement->setTable($tableparam);
$statement->setComment('Initial ' . $typename . ' of records on table ' . $tableparam);
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
}
}
if (!$changeme_exists) { /// Lets create the table
- $field = new XMLDBField('id');
+ $field = new xmldb_field('id');
$field->setType(XMLDB_TYPE_INTEGER);
$field->setLength(10);
$field->setNotNull(true);
$field->setLoaded(true);
$field->setChanged(true);
- $key = new XMLDBKey('primary');
+ $key = new xmldb_key('primary');
$key->setType(XMLDB_KEY_PRIMARY);
$key->setFields(array('id'));
$key->setLoaded(true);
$key->setChanged(true);
- $table = new XMLDBTable('changeme');
+ $table = new xmldb_table('changeme');
$table->setComment('Default comment for the table, please edit me');
$table->addField($field);
$table->addKey($key);
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
///////////////////////////////////////////////////////////////////////////
/// This class will ask and retrofit all the information from one
-/// mysql table present in the Moodle DB to one XMLDBTable structure
+/// mysql table present in the Moodle DB to one xmldb_table structure
class new_table_from_mysql extends XMLDBAction {
$tableparam = required_param('table', PARAM_CLEAN);
$afterparam = required_param('after', PARAM_CLEAN);
- /// Create one new XMLDBTable
- $table = new XMLDBTable(strtolower(trim($tableparam)));
+ /// Create one new xmldb_table
+ $table = new xmldb_table(strtolower(trim($tableparam)));
$table->setComment($table->getName() . ' table retrofitted from MySQL');
/// Get fields info from ADODb
$dbfields = $DB->get_columns($tableparam);
if ($dbfields) {
foreach ($dbfields as $dbfield) {
/// Create new XMLDB field
- $field = new XMLDBField($dbfield->name);
+ $field = new xmldb_field($dbfield->name);
/// Set field with info retrofitted
$field->setFromADOField($dbfield);
/// Add field to the table
foreach ($dbindexes as $indexname => $dbindex) {
/// Add the indexname to the array
$dbindex['name'] = $indexname;
- /// We are handling one XMLDBKey (primaries + uniques)
+ /// We are handling one xmldb_key (primaries + uniques)
if ($dbindex['unique']) {
- $key = new XMLDBKey(strtolower($dbindex['name']));
+ $key = new xmldb_key(strtolower($dbindex['name']));
/// Set key with info retrofitted
$key->setFromADOKey($dbindex);
/// Set default comment to PKs
/// Add key to the table
$table->addKey($key);
- /// We are handling one XMLDBIndex (non-uniques)
+ /// We are handling one xmldb_index (non-uniques)
} else {
- $index = new XMLDBIndex(strtolower($dbindex['name']));
+ $index = new xmldb_index(strtolower($dbindex['name']));
/// Set index with info retrofitted
$index->setFromADOIndex($dbindex);
/// Add index to the table
$o = $b;
/// Silenty drop any previous test tables
- $table = new XMLDBTable('testtable');
+ $table = new xmldb_table('testtable');
if ($dbman->table_exists($table)) {
$status = $dbman->drop_table($table, true, false);
}
- $table = new XMLDBTable ('anothertest');
+ $table = new xmldb_table ('anothertest');
if ($dbman->table_exists($table)) {
$status = $dbman->drop_table($table, true, false);
}
- $table = new XMLDBTable ('newnameforthetable');
+ $table = new xmldb_table ('newnameforthetable');
if ($dbman->table_exists($table)) {
$status = $dbman->drop_table($table, true, false);
}
/// 1st test. Complete table creation.
- $table = new XMLDBTable('testtable');
+ $table = new xmldb_table('testtable');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general');
/// 3rd test. creating another, smaller table
if ($test->status) {
- $table = new XMLDBTable ('anothertest');
+ $table = new xmldb_table ('anothertest');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '30', null, null, null, null, null, 'Moodle');
/// 4th test. Adding one complex enum field
if ($test->status) {
/// Create a new field with complex specs (enums are good candidates)
- $field = new XMLDBField('type');
+ $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');
/// Get SQL code and execute it
$test = new stdClass;
/// 6th test. Adding one complex enum field
if ($test->status) {
/// Create a new field with complex specs (enums are good candidates)
- $field = new XMLDBField('type');
+ $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');
/// Get SQL code and execute it
$test = new stdClass;
/// 7th test. Adding one numeric field
if ($test->status) {
/// Create a new field (numeric)
- $field = new XMLDBField('onenumber');
+ $field = new xmldb_field('onenumber');
$field->setAttributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'type');
/// Get SQL code and execute it
$test = new stdClass;
/// 8th test. Dropping one complex enum field
if ($test->status) {
/// Create a new field with complex specs (enums are good candidates)
- $field = new XMLDBField('type');
+ $field = new xmldb_field('type');
$test = new stdClass;
$test->sql = $gen->getDropFieldSQL($table, $field);
$test->status = $dbman->drop_field($table, $field, false, false);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('course');
+ $field = new xmldb_field('course');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, '0');
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('course');
+ $field = new xmldb_field('course');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, "test'n drop");
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_FLOAT, '20,10', XMLDB_UNSIGNED, null, null, null, null, null);
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'test');
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_NUMBER, '20,10', XMLDB_UNSIGNED, null, null, null, null, null);
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('intro');
+ $field = new xmldb_field('intro');
$field->setAttributes(XMLDB_TYPE_TEXT, 'big', null, XMLDB_NOTNULL, null, null, null, null);
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('secondname');
+ $field = new xmldb_field('secondname');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null);
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_NUMBER, '10,2', null, null, null, null, null, null);
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('course');
+ $field = new xmldb_field('course');
$field->setAttributes(XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_NUMBER, '10,2', XMLDB_UNSIGNED, null, null, null, null, null);
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_NUMBER, '10,2', null, null, null, null, null, null);
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('name');
+ $field = new xmldb_field('name');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, 'Moodle');
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('name');
+ $field = new xmldb_field('name');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, 'Moodle');
$test->sql = $gen->getAlterFieldSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('name');
+ $field = new xmldb_field('name');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, null);
$test->sql = $gen->getModifyDefaultSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('name');
+ $field = new xmldb_field('name');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, 'Moodle');
$test->sql = $gen->getModifyDefaultSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('secondname');
+ $field = new xmldb_field('secondname');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'Moodle2');
$test->sql = $gen->getModifyDefaultSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('secondname');
+ $field = new xmldb_field('secondname');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null);
$test->sql = $gen->getModifyDefaultSQL($table, $field);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $index = new XMLDBIndex('secondname');
+ $index = new xmldb_index('secondname');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('name', 'secondname', 'grade'));
$test->sql = $gen->getAddIndexSQL($table, $index);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $index = new XMLDBIndex('secondname');
+ $index = new xmldb_index('secondname');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course', 'name'));
$test->sql = $gen->getAddIndexSQL($table, $index);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $index = new XMLDBIndex('secondname');
+ $index = new xmldb_index('secondname');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('name', 'course'));
if ($indexfound = $dbman->find_index_name($table, $index)) {
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $index = new XMLDBIndex('name');
+ $index = new xmldb_index('name');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('name', 'grade', 'secondname'));
$test->sql = $gen->getDropIndexSQL($table, $index);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $key = new XMLDBKey('id-course-grade');
+ $key = new xmldb_key('id-course-grade');
$key->setAttributes(XMLDB_KEY_UNIQUE, array('id', 'course', 'grade'));
$test->sql = $gen->getAddKeySQL($table, $key);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $key = new XMLDBKey('course');
+ $key = new xmldb_key('course');
$key->setAttributes(XMLDB_KEY_FOREIGN_UNIQUE, array('course'), 'anothertest', array('id'));
$test->sql = $gen->getAddKeySQL($table, $key);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $key = new XMLDBKey('course');
+ $key = new xmldb_key('course');
$key->setAttributes(XMLDB_KEY_FOREIGN_UNIQUE, array('course'), 'anothertest', array('id'));
$test->sql = $gen->getDropKeySQL($table, $key);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $key = new XMLDBKey('course');
+ $key = new xmldb_key('course');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('course'), 'anothertest', array('id'));
$test->sql = $gen->getAddKeySQL($table, $key);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $key = new XMLDBKey('course');
+ $key = new xmldb_key('course');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('course'), 'anothertest', array('id'));
$test->sql = $gen->getDropKeySQL($table, $key);
/// 36th test. Adding one complex enum field
if ($test->status) {
/// Create a new field with complex specs (enums are good candidates)
- $field = new XMLDBField('type');
+ $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');
/// Get SQL code and execute it
$test = new stdClass;
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('type');
+ $field = new xmldb_field('type');
$field->setAttributes(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 XMLDBField('type');
+ $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');
$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 XMLDBIndex('anyname');
+ $index = new xmldb_index('anyname');
$index->setAttributes(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 XMLDBKey('anyname');
+ $key = new xmldb_key('anyname');
$key->setAttributes(XMLDB_KEY_UNIQUE, array('id', 'course', 'grade'));
$test->sql = $gen->getRenameKeySQL($table, $key, 'newnameforthekey', true);
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
- $field = new XMLDBField('type');
+ $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');
$test->sql = $gen->getRenameFieldSQL($table, $field, 'newnameforthefield', true);
if ($test->status) {
/// Add enum to field containing enum
$table->setName('newnameforthetable');
- $field = new XMLDBField('newnameforthefield');
+ $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');
/// Get SQL code and execute it
$test = new stdClass;
if ($test->status) {
/// Drop enum from field containing enum
$table->setName('newnameforthetable');
- $field = new XMLDBField('newnameforthefield');
+ $field = new xmldb_field('newnameforthefield');
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'general', 'course');
/// Get SQL code and execute it
$test = new stdClass;
if ($test->status) {
/// Drop enum from field not containing enum
$table->setName('newnameforthetable');
- $field = new XMLDBField('newnameforthefield');
+ $field = new xmldb_field('newnameforthefield');
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'general', 'course');
/// Get SQL code and execute it
$test = new stdClass;
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Define table ' . $table->getName() . ' to be created' . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
+ $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
$result .= XMLDB_LINEFEED;
$result .= ' /// Adding fields to table ' . $table->getName() . XMLDB_LINEFEED;
/// Iterate over each field
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Define table ' . $table->getName() . ' to be dropped' . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
+ $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
/// Launch the proper DDL
$result .= XMLDB_LINEFEED;
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Define table ' . $table->getName() . ' to be renamed to NEWNAMEGOESHERE' . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
+ $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
/// Launch the proper DDL
$result .= XMLDB_LINEFEED;
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Define field ' . $field->getName() . ' to be added to ' . $table->getName() . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $field = new XMLDBField(' . "'" . $field->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Define field ' . $field->getName() . ' to be dropped from ' . $table->getName() . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $field = new XMLDBField(' . "'" . $field->getName() . "'" . ');' . XMLDB_LINEFEED;
+ $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
+ $result .= ' $field = new xmldb_field(' . "'" . $field->getName() . "'" . ');' . XMLDB_LINEFEED;
/// Launch the proper DDL
$result .= XMLDB_LINEFEED;
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Rename field ' . $field->getName() . ' on table ' . $table->getName() . ' to NEWNAMEGOESHERE'. XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $field = new XMLDBField(' . "'" . $field->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Changing type of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $type . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $field = new XMLDBField(' . "'" . $field->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Changing precision of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $precision . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $field = new XMLDBField(' . "'" . $field->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Changing sign of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $unsigned . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $field = new XMLDBField(' . "'" . $field->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Changing nullability of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $notnull . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $field = new XMLDBField(' . "'" . $field->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Changing list of values (enum) of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $enum . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $field = new XMLDBField(' . "'" . $field->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Changing the default of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $default . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $field = new XMLDBField(' . "'" . $field->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Define key ' . $key->getName() . ' ('. $key->getXMLDBKeyName($key->getType()) . ') to be added to ' . $table->getName() . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $key = new XMLDBKey(' . "'" . $key->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Define key ' . $key->getName() . ' ('. $key->getXMLDBKeyName($key->getType()) . ') to be dropped form ' . $table->getName() . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $key = new XMLDBKey(' . "'" . $key->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Define key ' . $key->getName() . ' ('. $key->getXMLDBKeyName($key->getType()) . ') to be renamed to NEWNAMEGOESHERE' . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $key = new XMLDBKey(' . "'" . $key->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Define index ' . $index->getName() . ' ('. ($index->getUnique() ? 'unique' : 'not unique') . ') to be added to ' . $table->getName() . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $index = new XMLDBIndex(' . "'" . $index->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Define index ' . $index->getName() . ' ('. ($index->getUnique() ? 'unique' : 'not unique') . ') to be dropped form ' . $table->getName() . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $index = new XMLDBIndex(' . "'" . $index->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;
/// Launch the proper DDL
/// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' /// Define index ' . $index->getName() . ' ('. ($index->getUnique() ? 'unique' : 'not unique') . ') to be renamed to NEWNAMEGOESHERE' . XMLDB_LINEFEED;
- $result .= ' $table = new XMLDBTable(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $index = new XMLDBIndex(' . "'" . $index->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;
/// Launch the proper DDL
require_once('../../lib/xmldb/xmldb_object.php');
require_once('../../lib/xmldb/xmldb_file.php');
require_once('../../lib/xmldb/xmldb_structure.php');
- require_once('../../lib/xmldb/XMLDBTable.class.php');
- require_once('../../lib/xmldb/XMLDBField.class.php');
- require_once('../../lib/xmldb/XMLDBKey.class.php');
- require_once('../../lib/xmldb/XMLDBIndex.class.php');
- require_once('../../lib/xmldb/XMLDBStatement.class.php');
+ require_once('../../lib/xmldb/xmldb_table.php');
+ require_once('../../lib/xmldb/xmldb_field.php');
+ require_once('../../lib/xmldb/xmldb_key.php');
+ require_once('../../lib/xmldb/xmldb_index.php');
+ require_once('../../lib/xmldb/xmldb_statement.php');
/// Add Moodle config script (this is loaded AFTER all the rest
/// of classes because it starts the SESSION and classes to be
if ($result && $oldversion < 2007081300) {
/// Changing nullability of field configdata on table block_instance to null
- $table = new XMLDBTable('block_instance');
- $field = new XMLDBField('configdata');
+ $table = new xmldb_table('block_instance');
+ $field = new xmldb_field('configdata');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'visible');
/// Launch change of nullability for field configdata
if ($result && $oldversion < 2008030700) {
/// Define index contextid-lowerboundary (not unique) to be dropped form grade_letters
- $table = new XMLDBTable('grade_letters');
- $index = new XMLDBIndex('contextid-lowerboundary');
+ $table = new xmldb_table('grade_letters');
+ $index = new xmldb_index('contextid-lowerboundary');
$index->setAttributes(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 XMLDBTable('grade_letters');
- $index = new XMLDBIndex('contextid-lowerboundary-letter');
+ $table = new xmldb_table('grade_letters');
+ $index = new xmldb_index('contextid-lowerboundary-letter');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('contextid', 'lowerboundary', 'letter'));
/// Launch add index contextid-lowerboundary-letter
if ($result && $oldversion < 2008050100) {
// Update courses that used weekscss to weeks
- $result = $DB->set_field('course', 'format', 'weeks', 'format', 'weekscss');
+ $result = $DB->set_field('course', 'format', 'weeks', array('format' => 'weekscss'));
upgrade_main_savepoint($result, 2008050100);
}
}
/// Define index idnumber (not unique) to be dropped form user
- $table = new XMLDBTable('user');
- $index = new XMLDBIndex('idnumber');
+ $table = new xmldb_table('user');
+ $index = new xmldb_index('idnumber');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
/// Launch drop index idnumber
}
/// Changing precision of field idnumber on table user to (255)
- $table = new XMLDBTable('user');
- $field = new XMLDBField('idnumber');
+ $table = new xmldb_table('user');
+ $field = new xmldb_field('idnumber');
$field->setAttributes(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 XMLDBIndex('idnumber');
+ $index = new xmldb_index('idnumber');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
$result = $result && $dbman->add_index($table, $index);
}
/**
- * Given one XMLDBTable, check if it exists in DB (true/false)
+ * Given one xmldb_table, check if it exists in DB (true/false)
*
- * @param mixed the table to be searched (string name or XMLDBTable instance)
+ * @param mixed the table to be searched (string name or xmldb_table instance)
* @return boolean true/false
*/
public function table_exists($table) {
}
/**
- * Given one XMLDBField, check if it exists in DB (true/false)
+ * Given one xmldb_field, check if it exists in DB (true/false)
*
- * @param mixed the table to be searched (string name or XMLDBTable instance)
- * @param mixed the field to be searched for (string name or XMLDBField instance)
+ * @param mixed the table to be searched (string name or xmldb_table instance)
+ * @param mixed the field to be searched for (string name or xmldb_field instance)
* @return boolean true/false
*/
public function field_exists($table, $field) {
}
/**
- * Given one XMLDBIndex, the function returns the name of the index in DB (if exists)
+ * Given one xmldb_index, the function returns the name of the index in DB (if exists)
* of false if it doesn't exist
*
- * @param mixed the table to be searched (string name or XMLDBTable instance)
- * @param XMLDBIndex the index to be searched
+ * @param mixed the table to be searched (string name or xmldb_table instance)
+ * @param xmldb_index the index to be searched
* @return string index name of false
*/
public function find_index_name($table, $xmldb_index) {
}
/**
- * Given one XMLDBIndex, check if it exists in DB (true/false)
+ * Given one xmldb_index, check if it exists in DB (true/false)
*
- * @param mixed the table to be searched (string name or XMLDBTable instance)
- * @param XMLDBIndex the index to be searched for
+ * @param mixed the table to be searched (string name or xmldb_table instance)
+ * @param xmldb_index the index to be searched for
* @return boolean true/false
*/
public function index_exists($table, $xmldb_index) {
}
/**
- * Given one XMLDBField, the function returns the name of the check constraint in DB (if exists)
+ * Given one xmldb_field, the function returns the name of the check constraint in DB (if exists)
* of false if it doesn't exist. Note that XMLDB limits the number of check constrainst per field
* to 1 "enum-like" constraint. So, if more than one is returned, only the first one will be
* retrieved by this funcion.
*
* @uses, $db
- * @param XMLDBTable the table to be searched
- * @param XMLDBField the field to be searched
+ * @param xmldb_table the table to be searched
+ * @param xmldb_field the field to be searched
* @return string check constraint name or false
*/
public function find_check_constraint_name($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBField, check if it has a check constraint in DB
+ * Given one xmldb_field, check if it has a check constraint in DB
*
* @uses, $db
- * @param XMLDBTable the table
- * @param XMLDBField the field to be searched for any existing constraint
+ * @param xmldb_table the table
+ * @param xmldb_field the field to be searched for any existing constraint
* @return boolean true/false
*/
public function check_constraint_exists($xmldb_table, $xmldb_field) {
* This function IS NOT IMPLEMENTED. ONCE WE'LL BE USING RELATIONAL
* INTEGRITY IT WILL BECOME MORE USEFUL. FOR NOW, JUST CALCULATE "OFFICIAL"
* KEY NAMES WITHOUT ACCESSING TO DB AT ALL.
- * Given one XMLDBKey, the function returns the name of the key in DB (if exists)
+ * Given one xmldb_key, the function returns the name of the key in DB (if exists)
* of false if it doesn't exist
*
* @uses, $db
- * @param XMLDBTable the table to be searched
- * @param XMLDBKey the key to be searched
+ * @param xmldb_table the table to be searched
+ * @param xmldb_key the key to be searched
* @return string key name of false
*/
public function find_key_name($xmldb_table, $xmldb_key) {
/// Extract key columns
- if (!($xmldb_key instanceof XMLDBKey)) {
- debugging("Wrong type for second parameter to database_manager::find_key_name. Should be XMLDBKey, got " . gettype($xmldb_key));
+ if (!($xmldb_key instanceof xmldb_key)) {
+ debugging("Wrong type for second parameter to database_manager::find_key_name. Should be xmldb_key, got " . gettype($xmldb_key));
return false;
}
/**
- * Given one XMLDBTable, the function returns the name of its sequence in DB (if exists)
+ * Given one xmldb_table, the function returns the name of its sequence in DB (if exists)
* of false if it doesn't exist
*
- * @param XMLDBTable the table to be searched
+ * @param xmldb_table the table to be searched
* @return string sequence name of false
*/
public function find_sequence_name($xmldb_table) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect find_sequence_name() $xmldb_table parameter');
return false;
}
* and all the associated objects (keys, indexes, constaints, sequences, triggers)
* will be dropped too.
*
- * @param XMLDBTable table object (just the name is mandatory)
+ * @param xmldb_table table object (just the name is mandatory)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function drop_table($xmldb_table, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect drop_table() $xmldb_table parameter');
return false;
}
* This function will create the table passed as argument with all its
* fields/keys/indexes/sequences, everything based in the XMLDB object
*
- * @param XMLDBTable table object (full specs are required)
+ * @param xmldb_table table object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function create_table($xmldb_table, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect create_table() $xmldb_table parameter');
return false;
}
* NOTE: The return value is the tablename - some DBs (MSSQL at least) use special
* names for temp tables.
*
- * @param XMLDBTable table object (full specs are required)
+ * @param xmldb_table table object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return string tablename on success, false on error
*/
function create_temp_table($xmldb_table, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect create_table() $xmldb_table parameter');
return false;
}
* This function will rename the table passed as argument
* Before renaming the index, the function will check it exists
*
- * @param XMLDBTable table object (just the name is mandatory)
+ * @param xmldb_table table object (just the name is mandatory)
* @param string new name of the index
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function rename_table($xmldb_table, $newname, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect rename_table() $xmldb_table parameter');
return false;
}
return false; //error!
}
- $check = new XMLDBTable($newname);
+ $check = new xmldb_table($newname);
/// Check table already renamed
if (!$this->table_exists($xmldb_table) and $this->table_exists($check)) {
* This function will add the field to the table passed as arguments
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBField field object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_field field object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function add_field($xmldb_table, $xmldb_field, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect add_field() $xmldb_table parameter');
return false;
}
- if (!($xmldb_field instanceof XMLDBField)) {
+ if (!($xmldb_field instanceof xmldb_field)) {
debugging('Incorrect add_field() $xmldb_field parameter');
return false;
}
* This function will drop the field from the table passed as arguments
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBField field object (just the name is mandatory)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_field field object (just the name is mandatory)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function drop_field($xmldb_table, $xmldb_field, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect drop_field() $xmldb_table parameter');
return false;
}
- if (!($xmldb_field instanceof XMLDBField)) {
+ if (!($xmldb_field instanceof xmldb_field)) {
debugging('Incorrect drop_field() $xmldb_field parameter');
return false;
}
* This function will change the type of the field in the table passed as arguments
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBField field object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_field field object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function change_field_type($xmldb_table, $xmldb_field, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect change_field_type() $xmldb_table parameter');
return false;
}
- if (!($xmldb_field instanceof XMLDBField)) {
+ if (!($xmldb_field instanceof xmldb_field)) {
debugging('Incorrect change_field_type() $xmldb_field parameter');
return false;
}
* This function will change the precision of the field in the table passed as arguments
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBField field object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_field field object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
* This function will change the unsigned/signed of the field in the table passed as arguments
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBField field object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_field field object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
* This function will change the nullability of the field in the table passed as arguments
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBField field object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_field field object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
/**
* This function will change the enum status of the field in the table passed as arguments
*
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBField field object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_field field object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function change_field_enum($xmldb_table, $xmldb_field, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect change_field_enum() $xmldb_table parameter');
return false;
}
- if (!($xmldb_field instanceof XMLDBField)) {
+ if (!($xmldb_field instanceof xmldb_field)) {
debugging('Incorrect change_field_enum() $xmldb_field parameter');
return false;
}
* One null value in the default field means delete the default
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBField field object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_field field object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function change_field_default($xmldb_table, $xmldb_field, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect change_field_default() $xmldb_table parameter');
return false;
}
- if (!($xmldb_field instanceof XMLDBField)) {
+ if (!($xmldb_field instanceof xmldb_field)) {
debugging('Incorrect change_field_default() $xmldb_field parameter');
return false;
}
* Before renaming the field, the function will check it exists
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBField index object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_field index object (full specs are required)
* @param string new name of the field
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function rename_field($xmldb_table, $xmldb_field, $newname, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect rename_field() $xmldb_table parameter');
return false;
}
- if (!($xmldb_field instanceof XMLDBField)) {
+ if (!($xmldb_field instanceof xmldb_field)) {
debugging('Incorrect rename_field() $xmldb_field parameter');
return false;
}
* This function will create the key in the table passed as arguments
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBKey index object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_key index object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function add_key($xmldb_table, $xmldb_key, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect add_key() $xmldb_table parameter');
return false;
}
- if (!($xmldb_key instanceof XMLDBKey)) {
+ if (!($xmldb_key instanceof xmldb_key)) {
debugging('Incorrect add_key() $xmldb_key parameter');
return false;
}
* This function will drop the key in the table passed as arguments
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBKey key object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_key key object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function drop_key($xmldb_table, $xmldb_key, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect drop_key() $xmldb_table parameter');
return false;
}
- if (!($xmldb_key instanceof XMLDBKey)) {
+ if (!($xmldb_key instanceof xmldb_key)) {
debugging('Incorrect drop_key() $xmldb_key parameter');
return false;
}
* Experimental. Shouldn't be used at all in normal installation/upgrade!
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBKey key object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_key key object (full specs are required)
* @param string new name of the key
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
public function rename_key($xmldb_table, $xmldb_key, $newname, $continue=true, $feedback=true) {
debugging('rename_key() is one experimental feature. You must not use it in production!', DEBUG_DEVELOPER);
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect rename_key() $xmldb_table parameter');
return false;
}
- if (!($xmldb_key instanceof XMLDBKey)) {
+ if (!($xmldb_key instanceof xmldb_key)) {
debugging('Incorrect rename_key() $xmldb_key parameter');
return false;
}
* Before creating the index, the function will check it doesn't exists
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBIndex index object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_index index object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function add_index($xmldb_table, $xmldb_intex, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect add_index() $xmldb_table parameter');
return false;
}
- if (!($xmldb_intex instanceof XMLDBIndex)) {
+ if (!($xmldb_intex instanceof xmldb_index)) {
debugging('Incorrect add_index() $xmldb_index parameter');
return false;
}
* Before dropping the index, the function will check it exists
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBIndex index object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_index index object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return boolean true on success, false on error
*/
public function drop_index($xmldb_table, $xmldb_intex, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect add_index() $xmldb_table parameter');
return false;
}
- if (!($xmldb_intex instanceof XMLDBIndex)) {
+ if (!($xmldb_intex instanceof xmldb_index)) {
debugging('Incorrect add_index() $xmldb_index parameter');
return false;
}
* Experimental. Shouldn't be used at all!
*
* @uses $CFG, $db
- * @param XMLDBTable table object (just the name is mandatory)
- * @param XMLDBIndex index object (full specs are required)
+ * @param xmldb_table table object (just the name is mandatory)
+ * @param xmldb_index index object (full specs are required)
* @param string new name of the index
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
public function rename_index($xmldb_table, $xmldb_intex, $newname, $continue=true, $feedback=true) {
debugging('rename_index() is one experimental feature. You must not use it in production!', DEBUG_DEVELOPER);
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect add_index() $xmldb_table parameter');
return false;
}
- if (!($xmldb_intex instanceof XMLDBIndex)) {
+ if (!($xmldb_intex instanceof xmldb_index)) {
debugging('Incorrect add_index() $xmldb_index parameter');
return false;
}
* names for temp tables.
*
* @uses $CFG, $db
- * @param XMLDBTable table object (full specs are required)
+ * @param xmldb_table table object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return string tablename on success, false on error
*/
function create_temp_table($xmldb_table, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect create_table() $xmldb_table parameter');
return false;
}
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop the field from the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop the field from the table
* MSSQL overwrites the standard sentence because it needs to do some extra work dropping the default and
* check constraints
*/
}
/**
- * Given one correct XMLDBField and the new name, returns the SQL statements
+ * Given one correct xmldb_field and the new name, returns the SQL statements
* to rename it (inside one array)
* MSSQL is special, so we overload the function here. It needs to
* drop the constraints BEFORE renaming the field
$results = array();
- $newt = new XMLDBTable($newname); //Temporal table for name calculations
+ $newt = new xmldb_table($newname); //Temporal table for name calculations
$oldtablename = $this->getTableName($xmldb_table);
$newtablename = $this->getTableName($newt);
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to alter the field in the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to alter the field in the table
*/
public function getAlterFieldSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to modify the default of the field in the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to modify the default of the field in the table
*/
public function getModifyDefaultSQL($xmldb_table, $xmldb_field) {
/// MSSQL is a bit special with default constraints because it implements them as external constraints so
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its enum
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to create its enum
* (usually invoked from getModifyEnumSQL()
*/
public function getCreateEnumSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its enum
* (usually invoked from getModifyEnumSQL()
*/
public function getDropEnumSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its default
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to create its default
* (usually invoked from getModifyDefaultSQL()
*/
public function getCreateDefaultSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its default
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its default
* (usually invoked from getModifyDefaultSQL()
*/
public function getDropDefaultSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, returns the name of its default constraint in DB
+ * Given one xmldb_table and one xmldb_field, returns the name of its default constraint in DB
* or false if not found
* This function should be considered internal and never used outside from generator
*/
}
/**
- * Given one XMLDBTable returns one array with all the check constrainsts
+ * Given one xmldb_table returns one array with all the check constrainsts
* in the table (fetched from DB)
* Optionally the function allows one xmldb_field to be specified in
* order to return only the check constraints belonging to one field.
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its enum
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to create its enum
* (usually invoked from getModifyEnumSQL()
*/
public function getCreateEnumSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its enum
* (usually invoked from getModifyEnumSQL()
*/
public function getDropEnumSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its default
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to create its default
* (usually invoked from getModifyDefaultSQL()
*/
public function getCreateDefaultSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one correct XMLDBField and the new name, returns the SQL statements
+ * Given one correct xmldb_field and the new name, returns the SQL statements
* to rename it (inside one array)
* MySQL is pretty diferent from the standard to justify this oveloading
*/
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its default
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its default
* (usually invoked from getModifyDefaultSQL()
*/
public function getDropDefaultSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable returns one array with all the check constrainsts
+ * Given one xmldb_table returns one array with all the check constrainsts
* in the table (fetched from DB)
* Optionally the function allows one xmldb_field to be specified in
* order to return only the check constraints belonging to one field.
public function isNameInUse($object_name, $type, $table_name) {
/// Calculate the real table name
- $xmldb_table = new XMLDBTable($table_name);
+ $xmldb_table = new xmldb_table($table_name);
$tname = $this->getTableName($xmldb_table);
switch($type) {
* names for temp tables.
*
* @uses $CFG, $db
- * @param XMLDBTable table object (full specs are required)
+ * @param xmldb_table table object (full specs are required)
* @param boolean continue to specify if must continue on error (true) or stop (false)
* @param boolean feedback to specify to show status info (true) or not (false)
* @return string tablename on success, false on error
*/
function create_temp_table($xmldb_table, $continue=true, $feedback=true) {
- if (!($xmldb_table instanceof XMLDBTable)) {
+ if (!($xmldb_table instanceof xmldb_table)) {
debugging('Incorrect create_table() $xmldb_table parameter');
return false;
}
* Returns the code (array of statements) needed to execute extra statements on table drop
*/
public function getDropTableExtraSQL($xmldb_table) {
- $xmldb_field = new XMLDBField('id'); // Fields having sequences should be exclusively, id.
+ $xmldb_field = new xmldb_field('id'); // Fields having sequences should be exclusively, id.
return $this->getDropSequenceSQL($xmldb_table, $xmldb_field, false);
}
$results = array();
- $xmldb_field = new XMLDBField('id'); // Fields having sequences should be exclusively, id.
+ $xmldb_field = new xmldb_field('id'); // Fields having sequences should be exclusively, id.
$oldseqname = $this->getSequenceFromDB($xmldb_table);
$newseqname = $this->getNameForObject($newname, $xmldb_field->getName(), 'seq');
/// Drop old trigger
$results[] = "DROP TRIGGER " . $oldtriggername;
- $newt = new XMLDBTable($newname); /// Temp table for trigger code generation
+ $newt = new xmldb_table($newname); /// Temp table for trigger code generation
/// Create new trigger
$results = array_merge($results, $this->getCreateTriggerSQL($newt, $xmldb_field));
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to alter the field in the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to alter the field in the table
* Oracle has some severe limits:
* - clob and blob fields doesn't allow type to be specified
* - error is dropped if the null/not null clause is specified and hasn't changed
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its enum
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to create its enum
* (usually invoked from getModifyEnumSQL()
*/
public function getCreateEnumSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its enum
* (usually invoked from getModifyEnumSQL()
*/
public function getDropEnumSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its default
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to create its default
* (usually invoked from getModifyDefaultSQL()
*/
public function getCreateDefaultSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its default
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its default
* (usually invoked from getModifyDefaultSQL()
*/
public function getDropDefaultSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable returns one array with all the check constrainsts
+ * Given one xmldb_table returns one array with all the check constrainsts
* in the table (fetched from DB)
* Optionally the function allows one xmldb_field to be specified in
* order to return only the check constraints belonging to one field.
}
/**
- * Given one XMLDBTable returns one string with the sequence of the table
+ * Given one xmldb_table returns one string with the sequence of the table
* in the table (fetched from DB)
* The sequence name for oracle is calculated by looking the corresponding
* trigger and retrieving the sequence name from it (because sequences are
}
/**
- * Given one XMLDBTable returns one string with the trigger
+ * Given one xmldb_table returns one string with the trigger
* in the table (fetched from DB)
* If no trigger is found, returns false
*/
$results = array();
- $newt = new XMLDBTable($newname);
+ $newt = new xmldb_table($newname);
- $xmldb_field = new XMLDBField('id'); // Fields having sequences should be exclusively, id.
+ $xmldb_field = new xmldb_field('id'); // Fields having sequences should be exclusively, id.
$oldseqname = $this->getTableName($xmldb_table) . '_' . $xmldb_field->getName() . '_seq';
$newseqname = $this->getTableName($newt) . '_' . $xmldb_field->getName() . '_seq';
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to add the field to the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to add the field to the table
* PostgreSQL is pretty standard but with one severe restriction under 7.4 that forces us to overload
* this function: Default clause is not allowed when adding fields.
*
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to alter the field in the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to alter the field in the table
* PostgreSQL has some severe limits:
* - Any change of type or precision requires a new temporary column to be created, values to
* be transfered potentially casting them, to apply defaults if the column is not null and
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its enum
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to create its enum
* (usually invoked from getModifyEnumSQL()
*/
public function getCreateEnumSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its enum
* (usually invoked from getModifyEnumSQL()
*/
public function getDropEnumSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to create its default
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to create its default
* (usually invoked from getModifyDefaultSQL()
*/
public function getCreateDefaultSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its default
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its default
* (usually invoked from getModifyDefaultSQL()
*/
public function getDropDefaultSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable returns one array with all the check constrainsts
+ * Given one xmldb_table returns one array with all the check constrainsts
* in the table (fetched from DB)
* Optionally the function allows one xmldb_field to be specified in
* order to return only the check constraints belonging to one field.
}
/**
- * Given one XMLDBTable returns one string with the sequence of the table
+ * Given one xmldb_table returns one string with the sequence of the table
* in the table (fetched from DB)
* The sequence name for Postgres has one standard name convention:
* tablename_fieldname_seq
public function setUp() {
global $CFG;
- $this->db = new mysql_adodb_moodle_database();
+ $this->db = new mysqli_adodb_moodle_database();
$this->db->connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->dbpersist, $CFG->prefix);
$this->dbmanager = $this->db->get_manager();
- $table = new XMLDBTable("testtable");
+ $table = new xmldb_table("testtable");
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('type', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM,
$this->tables[] = $table;
// Second, smaller table
- $table = new XMLDBTable ('anothertest');
+ $table = new xmldb_table ('anothertest');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, '30', null, null, null, null, null, 'Moodle');
}
public function testCreateTable() {
- $table = new XMLDBTable("other_test_table");
- $field = new XMLDBField('id');
+ $table = new xmldb_table("other_test_table");
+ $field = new xmldb_field('id');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true);
$table->addField($field);
- $key = new XMLDBKey('PRIMARY');
+ $key = new xmldb_key('PRIMARY');
$key->setAttributes(XMLDB_KEY_PRIMARY, array('id'));
$table->addKey($key);
public function testAddEnumField() {
$table = $this->tables[0];
/// Create a new field with complex specs (enums are good candidates)
- $field = new XMLDBField('type2');
+ $field = new xmldb_field('type2');
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM,
array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
$this->assertTrue($this->dbmanager->add_field($table, $field));
public function testAddNumericField() {
$table = $this->tables[0];
/// Create a new field with complex specs (enums are good candidates)
- $field = new XMLDBField('onenumber');
+ $field = new xmldb_field('onenumber');
$field->setAttributes(XMLDB_TYPE_INTEGER, '6', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'type');
$this->assertTrue($this->dbmanager->add_field($table, $field));
$this->assertTrue($this->dbmanager->field_exists($table, 'onenumber'));
public function testChangeFieldType() {
$table = $this->tables[1];
- $field = new XMLDBField('course');
+ $field = new xmldb_field('course');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, '0');
$this->assertTrue($this->dbmanager->change_field_type($this->tables[1], $field));
- $field = new XMLDBField('course');
+ $field = new xmldb_field('course');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$this->assertTrue($this->dbmanager->change_field_type($this->tables[1], $field));
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, "test'n drop");
$this->assertTrue($this->dbmanager->change_field_type($this->tables[1], $field));
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_FLOAT, '20,10', XMLDB_UNSIGNED, null, null, null, null, null);
$this->assertTrue($this->dbmanager->change_field_type($this->tables[1], $field));
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'test');
$this->assertTrue($this->dbmanager->change_field_type($this->tables[1], $field));
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_NUMBER, '20,10', XMLDB_UNSIGNED, null, null, null, null, null);
$this->assertTrue($this->dbmanager->change_field_type($this->tables[1], $field));
}
public function testChangeFieldPrecision() {
$table = $this->tables[1];
- $field = new XMLDBField('intro');
+ $field = new xmldb_field('intro');
$field->setAttributes(XMLDB_TYPE_TEXT, 'big', null, XMLDB_NOTNULL, null, null, null, null);
$this->assertTrue($this->dbmanager->change_field_precision($this->tables[1], $field));
- $field = new XMLDBField('secondname');
+ $field = new xmldb_field('secondname');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null);
$this->assertTrue($this->dbmanager->change_field_precision($this->tables[1], $field));
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_NUMBER, '10,2', null, null, null, null, null, null);
$this->assertTrue($this->dbmanager->change_field_precision($this->tables[1], $field));
- $field = new XMLDBField('course');
+ $field = new xmldb_field('course');
$field->setAttributes(XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
$this->assertTrue($this->dbmanager->change_field_precision($this->tables[1], $field));
}
public function testChangeFieldSign() {
$table = $this->tables[1];
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_NUMBER, '10,2', XMLDB_UNSIGNED, null, null, null, null, null);
$this->assertTrue($this->dbmanager->change_field_unsigned($this->tables[1], $field));
- $field = new XMLDBField('grade');
+ $field = new xmldb_field('grade');
$field->setAttributes(XMLDB_TYPE_NUMBER, '10,2', null, null, null, null, null, null);
$this->assertTrue($this->dbmanager->change_field_unsigned($this->tables[1], $field));
}
public function testChangeFieldNullability() {
$table = $this->tables[1];
- $field = new XMLDBField('name');
+ $field = new xmldb_field('name');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, 'Moodle');
$this->assertTrue($this->dbmanager->change_field_notnull($this->tables[1], $field));
- $field = new XMLDBField('name');
+ $field = new xmldb_field('name');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, 'Moodle');
$this->assertTrue($this->dbmanager->change_field_notnull($this->tables[1], $field));
}
public function testChangeFieldDefault() {
$table = $this->tables[1];
- $field = new XMLDBField('name');
+ $field = new xmldb_field('name');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, null);
$this->assertTrue($this->dbmanager->change_field_default($this->tables[1], $field));
- $field = new XMLDBField('name');
+ $field = new xmldb_field('name');
$field->setAttributes(XMLDB_TYPE_CHAR, '30', null, null, null, null, null, 'Moodle');
$this->assertTrue($this->dbmanager->change_field_default($this->tables[1], $field));
- $field = new XMLDBField('secondname');
+ $field = new xmldb_field('secondname');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, 'Moodle2');
$this->assertTrue($this->dbmanager->change_field_default($this->tables[1], $field));
- $field = new XMLDBField('secondname');
+ $field = new xmldb_field('secondname');
$field->setAttributes(XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null);
$this->assertTrue($this->dbmanager->change_field_default($this->tables[1], $field));
}
public function testAddUniqueIndex() {
$table = $this->tables[1];
- $index = new XMLDBIndex('secondname');
+ $index = new xmldb_index('secondname');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('name', 'secondname', 'grade'));
$this->assertTrue($this->dbmanager->add_index($this->tables[1], $index));
}
public function testAddNonUniqueIndex() {
$table = $this->tables[1];
- $index = new XMLDBIndex('secondname');
+ $index = new xmldb_index('secondname');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course', 'name'));
$this->assertTrue($this->dbmanager->add_index($this->tables[1], $index));
}
public function testFindIndexName() {
$table = $this->tables[1];
- $index = new XMLDBIndex('secondname');
+ $index = new xmldb_index('secondname');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course', 'name'));
$this->dbmanager->add_index($this->tables[1], $index);
// TODO DBM Systems name their indices differently. Maybe just test for non-false (or simply true)
$this->assertEqual($this->dbmanager->find_index_name($this->tables[1], $index), 'mdl_anot_counam_ix');
- $nonexistentindex = new XMLDBIndex('nonexistentindex');
+ $nonexistentindex = new xmldb_index('nonexistentindex');
$nonexistentindex->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('name'));
$this->assertFalse($this->dbmanager->find_index_name($this->tables[1], $nonexistentindex));
}
public function testDropIndex() {
$table = $this->tables[1];
- $index = new XMLDBIndex('secondname');
+ $index = new xmldb_index('secondname');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course', 'name'));
$this->dbmanager->add_index($this->tables[1], $index);
public function testAddUniqueKey() {
$table = $this->tables[1];
- $key = new XMLDBKey('id-course-grade');
+ $key = new xmldb_key('id-course-grade');
$key->setAttributes(XMLDB_KEY_UNIQUE, array('id', 'course', 'grade'));
$this->assertTrue($this->dbmanager->add_key($this->tables[1], $key));
}
public function testAddForeignUniqueKey() {
$table = $this->tables[1];
- $key = new XMLDBKey('course');
+ $key = new xmldb_key('course');
$key->setAttributes(XMLDB_KEY_FOREIGN_UNIQUE, array('course'), 'anothertest', array('id'));
$this->assertTrue($this->dbmanager->add_key($this->tables[1], $key));
}
public function testDropKey() {
$table = $this->tables[1];
- $key = new XMLDBKey('course');
+ $key = new xmldb_key('course');
$key->setAttributes(XMLDB_KEY_FOREIGN_UNIQUE, array('course'), 'anothertest', array('id'));
$this->dbmanager->add_key($this->tables[1], $key);
public function testAddForeignKey() {
$table = $this->tables[1];
- $key = new XMLDBKey('course');
+ $key = new xmldb_key('course');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('course'), 'anothertest', array('id'));
$this->assertTrue($this->dbmanager->add_key($this->tables[1], $key));
}
public function testDropForeignKey() {
$table = $this->tables[1];
- $key = new XMLDBKey('course');
+ $key = new xmldb_key('course');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('course'), 'anothertest', array('id'));
$this->dbmanager->add_key($this->tables[1], $key);
public function testChangeFieldEnum() {
$table = $this->tables[0];
// Removing an enum value
- $field = new XMLDBField('type');
+ $field = new xmldb_field('type');
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM,
array('news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
$this->assertTrue($this->dbmanager->change_field_enum($table, $field));
// Adding an enum value
- $field = new XMLDBField('type');
+ $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');
$this->assertTrue($this->dbmanager->change_field_enum($table, $field));
public function testRenameIndex() {
$table = $this->tables[0];
- $index = new XMLDBIndex('course');
+ $index = new xmldb_index('course');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('course'));
$this->assertTrue($this->dbmanager->rename_index($table, $index, 'newindexname'));
public function testRenameKey() {
$table = $this->tables[0];
- $key = new XMLDBKey('course');
+ $key = new xmldb_key('course');
$key->setAttributes(XMLDB_KEY_UNIQUE, array('course'));
$this->assertTrue($this->dbmanager->rename_key($table, $key, 'newkeyname'));
public function testRenameField() {
$table = $this->tables[0];
- $field = new XMLDBField('type');
+ $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');
$this->assertTrue($this->dbmanager->table_exists('testtable'));
// Test giving a table object
- $nonexistenttable = new XMLDBTable('nonexistenttable');
+ $nonexistenttable = new xmldb_table('nonexistenttable');
$this->assertFalse($this->dbmanager->table_exists($nonexistenttable));
$this->assertTrue($this->dbmanager->table_exists($table));
}
$realfield = $table->getField('id');
// Give a nonexistent table as first param
- $nonexistenttable = new XMLDBTable('nonexistenttable');
+ $nonexistenttable = new xmldb_table('nonexistenttable');
$this->assertFalse($this->dbmanager->field_exists($nonexistenttable, $realfield));
// Give a nonexistent field as second param
- $nonexistentfield = new XMLDBField('nonexistentfield');
+ $nonexistentfield = new xmldb_field('nonexistentfield');
$this->assertFalse($this->dbmanager->field_exists($table, $nonexistentfield));
// Correct string params
$this->assertFalse($this->dbmanager->find_sequence_name($table));
// give nonexistent table param
- $table = new XMLDBTable("nonexistenttable");
+ $table = new xmldb_table("nonexistenttable");
$this->assertFalse($this->dbmanager->find_sequence_name($table));
// Give existing and valid table param
}
/**
- * Given one XMLDBTable, returns it's correct name, depending of all the parametrization
+ * Given one xmldb_table, returns it's correct name, depending of all the parametrization
*
- * @param XMLDBTable table whose name we want
+ * @param xmldb_table table whose name we want
* @param boolean to specify if the name must be quoted (if reserved word, only!)
* @return string the correct name of the table
*/
}
/**
- * Given one correct XMLDBTable, returns the SQL statements
+ * Given one correct xmldb_table, returns the SQL statements
* to create it (inside one array)
*/
public function getCreateTableSQL($xmldb_table) {
/// automatically by the RDBMS) create the underlying (created by us) index (if doesn't exists)
if (!$this->getKeySQL($xmldb_table, $xmldb_key) || $xmldb_key->getType() == XMLDB_KEY_FOREIGN) {
/// Create the interim index
- $index = new XMLDBIndex('anyname');
+ $index = new xmldb_index('anyname');
$index->setFields($xmldb_key->getFields());
///Only process all this if the index doesn't exist in DB
if (!$this->mdb->get_manager()->index_exists($xmldb_table, $index)) {
}
/**
- * Given one correct XMLDBIndex, returns the SQL statements
+ * Given one correct xmldb_index, returns the SQL statements
* needed to create it (in array)
*/
public function getCreateIndexSQL($xmldb_table, $xmldb_index) {
}
/**
- * Given one correct XMLDBField, returns the complete SQL line to create it
+ * Given one correct xmldb_field, returns the complete SQL line to create it
*/
public function getFieldSQL($xmldb_field, $skip_type_clause = NULL, $skip_default_clause = NULL, $skip_notnull_clause = NULL, $specify_nulls_clause = NULL) {
}
/**
- * Given one correct XMLDBKey, returns its specs
+ * Given one correct xmldb_key, returns its specs
*/
public function getKeySQL($xmldb_table, $xmldb_key) {
}
/**
- * Give one XMLDBField, returns the correct "default value" for the current configuration
+ * Give one xmldb_field, returns the correct "default value" for the current configuration
*/
public function getDefaultValue($xmldb_field) {
}
/**
- * Given one XMLDBField, returns the correct "default clause" for the current configuration
+ * Given one xmldb_field, returns the correct "default clause" for the current configuration
*/
public function getDefaultClause($xmldb_field) {
}
/**
- * Given one correct XMLDBTable and the new name, returns the SQL statements
+ * Given one correct xmldb_table and the new name, returns the SQL statements
* to rename it (inside one array)
*/
public function getRenameTableSQL($xmldb_table, $newname) {
$results = array(); //Array where all the sentences will be stored
- $newt = new XMLDBTable($newname); //Temporal table for name calculations
+ $newt = new xmldb_table($newname); //Temporal table for name calculations
$rename = str_replace('OLDNAME', $this->getTableName($xmldb_table), $this->rename_table_sql);
$rename = str_replace('NEWNAME', $this->getTableName($newt), $rename);
}
/**
- * Given one correct XMLDBTable and the new name, returns the SQL statements
+ * Given one correct xmldb_table and the new name, returns the SQL statements
* to drop it (inside one array)
*/
public function getDropTableSQL($xmldb_table) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to add the field to the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to add the field to the table
*/
public function getAddFieldSQL($xmldb_table, $xmldb_field, $skip_type_clause = NULL, $skip_default_clause = NULL, $skip_notnull_clause = NULL) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop the field from the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop the field from the table
*/
public function getDropFieldSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to alter the field in the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to alter the field in the table
*/
public function getAlterFieldSQL($xmldb_table, $xmldb_field, $skip_type_clause = NULL, $skip_default_clause = NULL, $skip_notnull_clause = NULL) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to modify the enum of the field in the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to modify the enum of the field in the table
*/
public function getModifyEnumSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to modify the default of the field in the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to modify the default of the field in the table
*/
public function getModifyDefaultSQL($xmldb_table, $xmldb_field) {
}
/**
- * Given one correct XMLDBField and the new name, returns the SQL statements
+ * Given one correct xmldb_field and the new name, returns the SQL statements
* to rename it (inside one array)
*/
public function getRenameFieldSQL($xmldb_table, $xmldb_field, $newname) {
}
/**
- * Given one XMLDBTable and one XMLDBKey, return the SQL statements needded to add the key to the table
+ * Given one xmldb_table and one xmldb_key, return the SQL statements needded to add the key to the table
* note that undelying indexes will be added as parametrised by $xxxx_keys and $xxxx_index parameters
*/
public function getAddKeySQL($xmldb_table, $xmldb_key) {
} else {
$indextype = XMLDB_INDEX_UNIQUE;
}
- $xmldb_index = new XMLDBIndex('anyname');
+ $xmldb_index = new xmldb_index('anyname');
$xmldb_index->setAttributes($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));
}
/**
- * Given one XMLDBTable and one XMLDBIndex, return the SQL statements needded to drop the index from the table
+ * Given one xmldb_table and one xmldb_index, return the SQL statements needded to drop the index from the table
*/
public function getDropKeySQL($xmldb_table, $xmldb_key) {
/// 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 XMLDBIndex('anyname');
+ $xmldb_index = new xmldb_index('anyname');
$xmldb_index->setAttributes(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));
}
/**
- * Given one XMLDBTable and one XMLDBKey, return the SQL statements needded to rename the key in the table
+ * Given one xmldb_table and one xmldb_key, return the SQL statements needded to rename the key in the table
* Experimental! Shouldn't be used at all!
*/
($xmldb_key->getType() == XMLDB_KEY_FOREIGN && !$this->foreign_keys) ||
($xmldb_key->getType() == XMLDB_KEY_FOREIGN_UNIQUE && !$this->unique_keys && !$this->foreign_keys)) {
/// We aren't generating this type of keys, delegate to child indexes
- $xmldb_index = new XMLDBIndex($xmldb_key->getName());
+ $xmldb_index = new xmldb_index($xmldb_key->getName());
$xmldb_index->setFields($xmldb_key->getFields());
return $this->getRenameIndexSQL($xmldb_table, $xmldb_index, $newname);
}
}
/**
- * Given one XMLDBTable and one XMLDBIndex, return the SQL statements needded to add the index to the table
+ * Given one xmldb_table and one xmldb_index, return the SQL statements needded to add the index to the table
*/
public function getAddIndexSQL($xmldb_table, $xmldb_index) {
}
/**
- * Given one XMLDBTable and one XMLDBIndex, return the SQL statements needded to drop the index from the table
+ * Given one xmldb_table and one xmldb_index, return the SQL statements needded to drop the index from the table
*/
public function getDropIndexSQL($xmldb_table, $xmldb_index) {
}
/**
- * Given one XMLDBTable and one XMLDBIndex, return the SQL statements needded to rename the index in the table
+ * Given one xmldb_table and one xmldb_index, return the SQL statements needded to rename the index in the table
* Experimental! Shouldn't be used at all!
*/
function getRenameIndexSQL($xmldb_table, $xmldb_index, $newname) {
/**
* Given one object name and it's type (pk, uk, fk, ck, ix, uix, seq, trg)
* return if such name is currently in use (true) or no (false)
- * (MySQL requires the whole XMLDBTable object to be specified, so we add it always)
+ * (MySQL requires the whole xmldb_table object to be specified, so we add it always)
* (invoked from getNameForObject()
* Only some DB have this implemented
*/
}
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its enum
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its enum
* (usually invoked from getModifyEnumSQL()
*/
public abstract function getDropEnumSQL($xmldb_table, $xmldb_field);
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to add its enum
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to add its enum
* (usually invoked from getModifyEnumSQL()
*/
public abstract function getCreateEnumSQL($xmldb_table, $xmldb_field);
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to drop its default
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its default
* (usually invoked from getModifyDefaultSQL()
*/
public abstract function getDropDefaultSQL($xmldb_table, $xmldb_field);
/**
- * Given one XMLDBTable and one optional XMLDBField, return one array with all the check
+ * Given one xmldb_table and one optional xmldb_field, return one array with all the check
* constrainst found for that table (or field). Must exist for each DB supported.
* (usually invoked from find_check_constraint_name)
*/
public abstract function getCheckConstraintsFromDB($xmldb_table, $xmldb_field=null);
/**
- * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to add its default
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needded to add its default
* (usually invoked from getModifyDefaultSQL()
*/
public abstract function getCreateDefaultSQL($xmldb_table, $xmldb_field);
require_once($CFG->libdir.'/xmldb/xmldb_object.php');
require_once($CFG->libdir.'/xmldb/xmldb_file.php');
require_once($CFG->libdir.'/xmldb/xmldb_structure.php');
-require_once($CFG->libdir.'/xmldb/XMLDBTable.class.php');
-require_once($CFG->libdir.'/xmldb/XMLDBField.class.php');
-require_once($CFG->libdir.'/xmldb/XMLDBKey.class.php');
-require_once($CFG->libdir.'/xmldb/XMLDBIndex.class.php');
-require_once($CFG->libdir.'/xmldb/XMLDBStatement.class.php');
+require_once($CFG->libdir.'/xmldb/xmldb_table.php');
+require_once($CFG->libdir.'/xmldb/xmldb_field.php');
+require_once($CFG->libdir.'/xmldb/xmldb_key.php');
+require_once($CFG->libdir.'/xmldb/xmldb_index.php');
+require_once($CFG->libdir.'/xmldb/xmldb_statement.php');
/// Add other libraries
require_once($CFG->libdir.'/xmlize.php');
// found orphan table --> delete it
if ($DB->get_manager()->table_exists($table)) {
- $xmldb_table = new XMLDBTable($table);
+ $xmldb_table = new xmldb_table($table);
$DB->get_manager()->drop_table($xmldb_table, true, $feedback);
}
}
if ($CFG->dbfamily === 'oracle' && ($returnid == true || !empty($foundclobs) || !empty($foundblobs))) {
/// We need this here (move this function to dmlib?)
include_once($CFG->libdir . '/ddllib.php');
- $xmldb_table = new XMLDBTable($table);
+ $xmldb_table = new xmldb_table($table);
$seqname = find_sequence_name($xmldb_table);
if (!$seqname) {
/// Fallback, seqname not found, something is wrong. Inform and use the alternative getNameForObject() method
$result = true;
/// Define table course_modules to be created
- $table = new XMLDBTable('course_modules');
+ $table = new xmldb_table('course_modules');
if (!table_exists($table)) {
/// Adding fields to table course_modules
}
/// Define table modules to be created
- $table = new XMLDBTable('modules');
+ $table = new xmldb_table('modules');
if (!table_exists($table)) {
}
/// Define table grade_items to be created
- $table = new XMLDBTable('grade_items');
+ $table = new xmldb_table('grade_items');
if (!table_exists($table)) {
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
/// Define table grade_categories to be created
- $table = new XMLDBTable('grade_categories');
+ $table = new xmldb_table('grade_categories');
if ($result && !table_exists($table)) {
/// Define table grade_grades to be created
- $table = new XMLDBTable('grade_grades');
+ $table = new xmldb_table('grade_grades');
if ($result && !table_exists($table)) {
/// Define table grade_outcomes to be created
- $table = new XMLDBTable('grade_outcomes');
+ $table = new xmldb_table('grade_outcomes');
if ($result && !table_exists($table)) {
/// Define table scale to be created
- $table = new XMLDBTable('scale');
+ $table = new xmldb_table('scale');
if ($result && !table_exists($table)) {
}
/// Define table quiz to be created
- $table = new XMLDBTable('quiz');
+ $table = new xmldb_table('quiz');
if ($result && !table_exists($table)) {
/// Adding fields to table quiz
$result = true;
/// Define table grade_items to be created
- $table = new XMLDBTable('grade_items_history');
+ $table = new xmldb_table('grade_items_history');
if (!table_exists($table)) {
}
/// Define table grade_categories to be created
- $table = new XMLDBTable('grade_categories_history');
+ $table = new xmldb_table('grade_categories_history');
if ($result && !table_exists($table)) {
/// Define table grade_grades to be created
- $table = new XMLDBTable('grade_grades_history');
+ $table = new xmldb_table('grade_grades_history');
if ($result && !table_exists($table)) {
/// Define table grade_outcomes to be created
- $table = new XMLDBTable('grade_outcomes_history');
+ $table = new xmldb_table('grade_outcomes_history');
if ($result && !table_exists($table)) {
}
/// Define table scale to be created
- $table = new XMLDBTable('scale_history');
+ $table = new xmldb_table('scale_history');
if ($result && !table_exists($table)) {
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
/// This class represent one XMLDB Field
-class XMLDBField extends xmldb_object {
+/// TODO: Delete for 2.1 (deeprecated in 2.0).
+/// Deprecated API starts here
+class XMLDBField extends xmldb_field {
+
+ function __construct($name) {
+ parent::__construct($name);
+ }
+
+}
+/// Deprecated API ends here
+
+class xmldb_field extends xmldb_object {
var $type;
var $length;
var $decimals;
/**
- * Creates one new XMLDBField
+ * Creates one new xmldb_field
*/
- function XMLDBField($name) {
+ function __construct($name) {
parent::__construct($name);
$this->type = NULL;
$this->length = NULL;
}
/**
- * Set all the attributes of one XMLDBField
+ * Set all the attributes of one xmldb_field
*
* @param string type XMLDB_TYPE_INTEGER, XMLDB_TYPE_NUMBER, XMLDB_TYPE_CHAR, XMLDB_TYPE_TEXT, XMLDB_TYPE_BINARY
* @param string precision length for integers and chars, two-comma separated numbers for numbers and 'small', 'medium', 'big' for texts and binaries
/**
* Load data from XML to the table
*/
- function arr2XMLDBField($xmlarr) {
+ function arr2xmldb_field($xmlarr) {
$result = true;
}
/**
- * This function calculate and set the hash of one XMLDBField
+ * This function calculate and set the hash of one xmldb_field
*/
function calculateHash($recursive = false) {
if (!$this->loaded) {
}
/**
- * This function will set all the attributes of the XMLDBField object
+ * This function will set all the attributes of the xmldb_field object
* based on information passed in one ADOField
*/
function setFromADOField($adofield) {
}
/**
- * Returns the PHP code needed to define one XMLDBField
+ * Returns the PHP code needed to define one xmldb_field
*/
function getPHP($includeprevious=true) {
/**
* Constructor of the xmldb_file
*/
- function __construct ($path) {
+ function __construct($path) {
parent::__construct($path);
$this->path = $path;
$this->xmldb_structure = NULL;
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
/// This class represent one XMLDB Index
-class XMLDBIndex extends xmldb_object {
+/// TODO: Delete for 2.1 (deeprecated in 2.0).
+/// Deprecated API starts here
+class XMLDBIndex extends xmldb_index {
+
+ function __construct($name) {
+ parent::__construct($name);
+ }
+
+}
+/// Deprecated API ends here
+
+class xmldb_index extends xmldb_object {
var $unique;
var $fields;
/**
- * Creates one new XMLDBIndex
+ * Creates one new xmldb_index
*/
- function XMLDBIndex($name) {
+ function __construct($name) {
parent::__construct($name);
$this->unique = false;
$this->fields = array();
}
/**
- * Set all the attributes of one XMLDBIndex
+ * 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
/**
* Load data from XML to the index
*/
- function arr2XMLDBIndex($xmlarr) {
+ function arr2xmldb_index($xmlarr) {
$result = true;
}
/**
- * This function calculate and set the hash of one XMLDBIndex
+ * This function calculate and set the hash of one xmldb_index
*/
function calculateHash($recursive = false) {
if (!$this->loaded) {
}
/**
- * This function will set all the attributes of the XMLDBIndex object
+ * This function will set all the attributes of the xmldb_index object
* based on information passed in one ADOindex
*/
function setFromADOIndex($adoindex) {
}
/**
- * Returns the PHP code needed to define one XMLDBIndex
+ * Returns the PHP code needed to define one xmldb_index
*/
function getPHP() {
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
/// This class represent one XMLDB Key
-class XMLDBKey extends xmldb_object {
+/// TODO: Delete for 2.1 (deeprecated in 2.0).
+/// Deprecated API starts here
+class XMLDBKey extends xmldb_key {
+
+ function __construct($name) {
+ parent::__construct($name);
+ }
+
+}
+/// Deprecated API ends here
+
+class xmldb_key extends xmldb_object {
var $type;
var $fields;
var $reffields;
/**
- * Creates one new XMLDBKey
+ * Creates one new xmldb_key
*/
- function XMLDBKey($name) {
+ function __construct($name) {
parent::__construct($name);
$this->type = NULL;
$this->fields = array();
}
/**
- * Set all the attributes of one XMLDBKey
+ * Set all the attributes of one xmldb_key
*
* @param string type XMLDB_KEY_PRIMARY, XMLDB_KEY_UNIQUE, XMLDB_KEY_FOREIGN
* @param array fields an array of fieldnames to build the key over
/**
* Load data from XML to the key
*/
- function arr2XMLDBKey($xmlarr) {
+ function arr2xmldb_key($xmlarr) {
$result = true;
}
/**
- * This function calculate and set the hash of one XMLDBKey
+ * This function calculate and set the hash of one xmldb_key
*/
function calculateHash($recursive = false) {
if (!$this->loaded) {
}
/**
- * This function will set all the attributes of the XMLDBKey object
+ * This function will set all the attributes of the xmldb_key object
* based on information passed in one ADOkey
*/
function setFromADOKey($adokey) {
}
/**
- * Returns the PHP code needed to define one XMLDBKey
+ * Returns the PHP code needed to define one xmldb_key
*/
function getPHP() {
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
/// (a group of SQL arbitrary sentences)
/// (only INSERT is allowed for now)
-class XMLDBStatement extends xmldb_object {
+/// TODO: Delete for 2.1 (deeprecated in 2.0).
+/// Deprecated API starts here
+class XMLDBStatement extends xmldb_statement {
+
+ function __construct($name) {
+ parent::__construct($name);
+ }
+
+}
+/// Deprecated API ends here
+
+class xmldb_statement extends xmldb_object {
var $table; // Table we are handling
var $type; // XMLDB_STATEMENT_TYPE
var $sentences; // Collection of sentences in the statement
/**
- * Creates one new XMLDBStatement
+ * Creates one new xmldb_statement
*/
- function XMLDBStatement($name) {
+ function __construct($name) {
parent::__construct($name);
$this->table = NULL;
$this->type = XMLDB_STATEMENT_INCORRECT;
/**
* Load data from XML to the index
*/
- function arr2XMLDBStatement($xmlarr) {
+ function arr2xmldb_statement($xmlarr) {
$result = true;
}
/**
- * This function calculate and set the hash of one XMLDBStatement
+ * This function calculate and set the hash of one xmldb_statement
*/
function calculateHash($recursive = false) {
if (!$this->loaded) {
*/
function xmlOutput() {
$o = '';
- $o.= ' <STATEMENT NAME="' . $this->name . '" TYPE="' . XMLDBStatement::getXMLDBStatementName($this->type) . '" TABLE="' . $this->table . '"';
+ $o.= ' <STATEMENT NAME="' . $this->name . '" TYPE="' . xmldb_statement::getXMLDBStatementName($this->type) . '" TABLE="' . $this->table . '"';
if ($this->comment) {
$o.= ' COMMENT="' . htmlspecialchars($this->comment) . '"';
}
}
/**
- * This function will set all the attributes of the XMLDBIndex object
+ * This function will set all the attributes of the xmldb_index object
* based on information passed in one ADOindex
*/
function setFromADOIndex($adoindex) {
/**
* Creates one new xmldb_structure
*/
- function construct($name) {
+ function __construct($name) {
parent::__construct($name);
$this->path = NULL;
$this->version = NULL;
}
/**
- * Returns one XMLDBTable
+ * Returns one xmldb_table
*/
function &getTable($tablename) {
$i = $this->findTableInArray($tablename);
}
/**
- * Returns one XMLDBStatement
+ * Returns one xmldb_statement
*/
function &getStatement($statementname) {
$i = $this->findStatementInArray($statementname);
continue;
}
$name = trim($xmltable['@']['NAME']);
- $table = new XMLDBTable($name);
- $table->arr2XMLDBTable($xmltable);
+ $table = new xmldb_table($name);
+ $table->arr2xmldb_table($xmltable);
$this->tables[] = $table;
if (!$table->isLoaded()) {
$this->errormsg = 'Problem loading table ' . $name;
continue;
}
$name = trim($xmlstatement['@']['NAME']);
- $statement = new XMLDBStatement($name);
- $statement->arr2XMLDBStatement($xmlstatement);
+ $statement = new xmldb_statement($name);
+ $statement->arr2xmldb_statement($xmlstatement);
$this->statements[] = $statement;
if (!$statement->isLoaded()) {
$this->errormsg = 'Problem loading statement ' . $name;
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
/// This class represent one XMLDB table
-class XMLDBTable extends xmldb_object {
+/// TODO: Delete for 2.1 (deeprecated in 2.0).
+/// Deprecated API starts here
+class XMLDBTable extends xmldb_table {
+
+ function __construct($name) {
+ parent::__construct($name);
+ }
+
+}
+/// Deprecated API ends here
+
+class xmldb_table extends xmldb_object {
var $fields;
var $keys;
var $indexes;
/**
- * Creates one new XMLDBTable
+ * Creates one new xmldb_table
*/
- function XMLDBTable($name) {
+ function __construct($name) {
parent::__construct($name);
$this->fields = array();
$this->keys = array();
}
/**
- * Returns one XMLDBField
+ * Returns one xmldb_field
*/
function &getField($fieldname) {
$i = $this->findFieldInArray($fieldname);
}
/**
- * Returns one XMLDBKey
+ * Returns one xmldb_key
*/
function &getKey($keyname) {
$i = $this->findKeyInArray($keyname);
}
/**
- * Returns one XMLDBIndex
+ * Returns one xmldb_index
*/
function &getIndex($indexname) {
$i = $this->findIndexInArray($indexname);
/**
* Load data from XML to the table
*/
- function arr2XMLDBTable($xmlarr) {
+ function arr2xmldb_table($xmlarr) {
global $CFG;
continue;
}
$name = trim($xmlfield['@']['NAME']);
- $field = new XMLDBField($name);
- $field->arr2XMLDBField($xmlfield);
+ $field = new xmldb_field($name);
+ $field->arr2xmldb_field($xmlfield);
$this->fields[] = $field;
if (!$field->isLoaded()) {
$this->errormsg = 'Problem loading field ' . $name;
continue;
}
$name = trim($xmlkey['@']['NAME']);
- $key = new XMLDBKey($name);
- $key->arr2XMLDBKey($xmlkey);
+ $key = new xmldb_key($name);
+ $key->arr2xmldb_key($xmlkey);
$this->keys[] = $key;
if (!$key->isLoaded()) {
$this->errormsg = 'Problem loading key ' . $name;
continue;
}
$name = trim($xmlindex['@']['NAME']);
- $index = new XMLDBIndex($name);
- $index->arr2XMLDBIndex($xmlindex);
+ $index = new xmldb_index($name);
+ $index->arr2xmldb_index($xmlindex);
$this->indexes[] = $index;
if (!$index->isLoaded()) {
$this->errormsg = 'Problem loading index ' . $name;
}
/**
- * This function calculate and set the hash of one XMLDBTable
+ * This function calculate and set the hash of one xmldb_table
*/
function calculateHash($recursive = false) {
if (!$this->loaded) {
* @param string previous name of the previous field in the table or null (or false)
*/
function addFieldInfo($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
- $field = new XMLDBField($name);
+ $field = new xmldb_field($name);
$field->setAttributes($type, $precision, $unsigned, $notnull, $sequence, $enum, $enumvalues, $default);
$this->addField($field, $previous);
* @param array reffields an array of fieldnames in the FK table or null
*/
function addKeyInfo($name, $type, $fields, $reftable=null, $reffields=null) {
- $key = new XMLDBKey($name);
+ $key = new xmldb_key($name);
$key->setAttributes($type, $fields, $reftable, $reffields);
$this->addKey($key);
}
* @param array fields an array of fieldnames to build the index over
*/
function addIndexInfo($name, $type, $fields) {
- $index = new XMLDBIndex($name);
+ $index = new xmldb_index($name);
$index->setAttributes($type, $fields);
$this->addIndex($index);
}
if ($result && $oldversion < 2007101512) {
/// Launch add field asearchtemplate again if does not exists yet - reported on several sites
- $table = new XMLDBTable('data');
- $field = new XMLDBField('asearchtemplate');
+ $table = new xmldb_table('data');
+ $field = new xmldb_field('asearchtemplate');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'jstemplate');
if (!$dbman->field_exists($table, $field)) {
$sql = "UPDATE {$CFG->prefix}data SET notification=0 WHERE notification IS NULL";
$result = $DB->execute($sql);
- $table = new XMLDBTable('data');
- $field = new XMLDBField('notification');
+ $table = new xmldb_table('data');
+ $field = new xmldb_field('notification');
// 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);
if ($result && $oldversion < 2007012310) {
//create a new table feedback_completedtmp and the field-definition
- $table = new XMLDBTable('feedback_completedtmp');
+ $table = new xmldb_table('feedback_completedtmp');
- $field = new XMLDBField('id');
+ $field = new xmldb_field('id');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null, null, null);
$table->addField($field);
- $field = new XMLDBField('feedback');
+ $field = new xmldb_field('feedback');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
$table->addField($field);
- $field = new XMLDBField('userid');
+ $field = new xmldb_field('userid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
$table->addField($field);
- $field = new XMLDBField('guestid');
+ $field = new xmldb_field('guestid');
$field->setAttributes(XMLDB_TYPE_CHAR, '255', null, null, false, null, null, '', null);
$table->addField($field);
- $field = new XMLDBField('timemodified');
+ $field = new xmldb_field('timemodified');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
$table->addField($field);
- $key = new XMLDBKey('PRIMARY');
+ $key = new xmldb_key('PRIMARY');
$key->setAttributes(XMLDB_KEY_PRIMARY, array('id'));
$table->addKey($key);
- $key = new XMLDBKey('feedback');
+ $key = new xmldb_key('feedback');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('feedback'), 'feedback', 'id');
$table->addKey($key);
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
//create a new table feedback_valuetmp and the field-definition
- $table = new XMLDBTable('feedback_valuetmp');
+ $table = new xmldb_table('feedback_valuetmp');
- $field = new XMLDBField('id');
+ $field = new xmldb_field('id');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null, null, null);
$table->addField($field);
- $field = new XMLDBField('course_id');
+ $field = new xmldb_field('course_id');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
$table->addField($field);
- $field = new XMLDBField('item');
+ $field = new xmldb_field('item');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
$table->addField($field);
- $field = new XMLDBField('completed');
+ $field = new xmldb_field('completed');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
$table->addField($field);
- $field = new XMLDBField('tmp_completed');
+ $field = new xmldb_field('tmp_completed');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, null, null, '0', null);
$table->addField($field);
- $field = new XMLDBField('value');
+ $field = new xmldb_field('value');
$field->setAttributes(XMLDB_TYPE_TEXT, null, null, null, false, null, null, '', null);
$table->addField($field);
- $key = new XMLDBKey('PRIMARY');
+ $key = new xmldb_key('PRIMARY');
$key->setAttributes(XMLDB_KEY_PRIMARY, array('id'));
$table->addKey($key);
- $key = new XMLDBKey('feedback');
+ $key = new xmldb_key('feedback');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('item'), 'feedback_item', 'id');
$table->addKey($key);
if ($result && $oldversion < 2007050504) {
/// Define field random_response to be added to feedback_completed
- $table = new XMLDBTable('feedback_completed');
- $field = new XMLDBField('random_response');
+ $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);
/// Launch add field1
$result = $result && $dbman->add_field($table, $field);
/// Define field anonymous_response to be added to feedback_completed
- $table = new XMLDBTable('feedback_completed');
- $field = new XMLDBField('anonymous_response');
+ $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);
/// Launch add field2
$result = $result && $dbman->add_field($table, $field);
/// Define field random_response to be added to feedback_completed
- $table = new XMLDBTable('feedback_completedtmp');
- $field = new XMLDBField('random_response');
+ $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);
/// Launch add field1
$result = $result && $dbman->add_field($table, $field);
/// Define field anonymous_response to be added to feedback_completed
- $table = new XMLDBTable('feedback_completedtmp');
- $field = new XMLDBField('anonymous_response');
+ $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);
/// Launch add field2
$result = $result && $dbman->add_field($table, $field);
if ($result && $oldversion < 2007102600) {
// public is a reserved word on Oracle
- $table = new XMLDBTable('feedback_template');
- $field = new XMLDBField('ispublic');
+ $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);
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 XMLDBTable('feedback');
- $field = new XMLDBField('autonumbering');
+ $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');
/// 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 XMLDBTable('feedback');
- $field = new XMLDBField('site_after_submit');
+ $table = new xmldb_table('feedback');
+ $field = new xmldb_field('site_after_submit');
$field->setAttributes(XMLDB_TYPE_CHAR, '255', null, null, false, null, null, '', 'autonumbering');
/// Launch add field2
$result = $result && $dbman->add_field($table, $field);
if ($result && $oldversion < 2008050105) {
//field count is not more needed
- $table = new XMLDBTable('feedback_tracking');
- $field = new XMLDBField('count');
+ $table = new xmldb_table('feedback_tracking');
+ $field = new xmldb_field('count');
$result = $result && $dbman->drop_field($table, $field);
}
return $result;
if ($result && $oldversion < 2007072201) {
- $table = new XMLDBTable('lesson');
- $field = new XMLDBField('usegrademax');
- $field2 = new XMLDBField('usemaxgrade');
+ $table = new xmldb_table('lesson');
+ $field = new xmldb_field('usegrademax');
+ $field2 = new xmldb_field('usemaxgrade');
/// 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)) {