From: stronk7 Date: Tue, 20 May 2008 23:24:40 +0000 (+0000) Subject: MDL-14863 - 1st iteration: lowercase XMLDB table, field, index, key and statement + X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a8cb94f66fe9248659f973a939b4f9b002e1b348;p=moodle.git MDL-14863 - 1st iteration: lowercase XMLDB table, field, index, key and statement + wrapper class to support old syntax (no changes in public API yet) --- diff --git a/admin/xmldb/actions/check_indexes/check_indexes.class.php b/admin/xmldb/actions/check_indexes/check_indexes.class.php index 5a177305df..7b347faab3 100644 --- a/admin/xmldb/actions/check_indexes/check_indexes.class.php +++ b/admin/xmldb/actions/check_indexes/check_indexes.class.php @@ -163,7 +163,7 @@ class check_indexes extends XMLDBAction { /// 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: diff --git a/admin/xmldb/actions/edit_field/edit_field.class.php b/admin/xmldb/actions/edit_field/edit_field.class.php index a9387c89da..04d79469ef 100644 --- a/admin/xmldb/actions/edit_field/edit_field.class.php +++ b/admin/xmldb/actions/edit_field/edit_field.class.php @@ -7,7 +7,7 @@ // 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 // @@ -117,7 +117,7 @@ class edit_field extends XMLDBAction { } /// XMLDB field comment $o.= ' '; - /// 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), @@ -137,25 +137,25 @@ class edit_field extends XMLDBAction { } $o.= ' '; $o.= ' ' . choose_from_menu($typeoptions, 'type', $field->getType(), '', '', '', true) . ''; - /// XMLDBField Length + /// xmldb_field Length $o.= ' '; $o.= ' '; - /// XMLDBField Decimals + /// xmldb_field Decimals $o.= ' '; $o.= ' '; - /// XMLDBField Unsigned + /// xmldb_field Unsigned $unsignedoptions = array (0 => 'signed', 1 => 'unsigned'); $o.= ' '; $o.= ' ' . choose_from_menu($unsignedoptions, 'unsigned', $field->getUnsigned(), '', '', '', true) . ''; - /// XMLDBField NotNull + /// xmldb_field NotNull $notnulloptions = array (0 => 'null', 'not null'); $o.= ' '; $o.= ' ' . choose_from_menu($notnulloptions, 'notnull', $field->getNotNull(), '', '', '', true) . ''; - /// XMLDBField Sequence + /// xmldb_field Sequence $sequenceoptions = array (0 => $this->str['no'], 1 => 'auto-numbered'); $o.= ' '; $o.= ' ' . choose_from_menu($sequenceoptions, 'sequence', $field->getSequence(), '', '', '', true) . ''; - /// XMLDBField Enum and enumvalues + /// xmldb_field Enum and enumvalues $enumoptions = array (0 => $this->str['no'], 1 => $this->str['yes']); $o.= ' '; $o.= ' ' . choose_from_menu($enumoptions, 'enum', $field->getEnum(), '', '', '', true) . ''; @@ -165,7 +165,7 @@ class edit_field extends XMLDBAction { $enumvalues = ''; } $o.= ' '; - /// XMLDBField Default + /// xmldb_field Default $o.= ' '; $o.= ' '; /// Change button diff --git a/admin/xmldb/actions/edit_field_save/edit_field_save.class.php b/admin/xmldb/actions/edit_field_save/edit_field_save.class.php index 5fa6bcb725..512b6c7c08 100644 --- a/admin/xmldb/actions/edit_field_save/edit_field_save.class.php +++ b/admin/xmldb/actions/edit_field_save/edit_field_save.class.php @@ -7,7 +7,7 @@ // 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 // @@ -271,7 +271,7 @@ class edit_field_save extends XMLDBAction { } if (!empty($errors)) { - $tempfield = new XMLDBField($name); + $tempfield = new xmldb_field($name); $tempfield->setType($type); $tempfield->setLength($length); $tempfield->setDecimals($decimals); diff --git a/admin/xmldb/actions/edit_index/edit_index.class.php b/admin/xmldb/actions/edit_index/edit_index.class.php index 54d2714c9f..7422b2311f 100644 --- a/admin/xmldb/actions/edit_index/edit_index.class.php +++ b/admin/xmldb/actions/edit_index/edit_index.class.php @@ -7,7 +7,7 @@ // 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 // @@ -115,12 +115,12 @@ class edit_index extends XMLDBAction { $o.= ' '; /// XMLDB key comment $o.= ' '; - /// XMLDBIndex Type + /// xmldb_index Type $typeoptions = array (0 => 'not unique', 1 => 'unique'); $o.= ' '; $o.= ' ' . choose_from_menu($typeoptions, 'unique', $index->getUnique(), '', '', '', true) . ''; - /// XMLDBIndex Fields + /// xmldb_index Fields $o.= ' '; $o.= ' '; /// Change button diff --git a/admin/xmldb/actions/edit_index_save/edit_index_save.class.php b/admin/xmldb/actions/edit_index_save/edit_index_save.class.php index 35df0d21ac..4d8f13942b 100644 --- a/admin/xmldb/actions/edit_index_save/edit_index_save.class.php +++ b/admin/xmldb/actions/edit_index_save/edit_index_save.class.php @@ -7,7 +7,7 @@ // 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 // @@ -159,7 +159,7 @@ class edit_index_save extends XMLDBAction { } if (!empty($errors)) { - $tempindex = new XMLDBIndex($name); + $tempindex = new xmldb_index($name); $tempindex->setUnique($unique); $tempindex->setFields($fieldsarr); /// Prepare the output diff --git a/admin/xmldb/actions/edit_key/edit_key.class.php b/admin/xmldb/actions/edit_key/edit_key.class.php index ac3f617f51..7858711939 100644 --- a/admin/xmldb/actions/edit_key/edit_key.class.php +++ b/admin/xmldb/actions/edit_key/edit_key.class.php @@ -7,7 +7,7 @@ // 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 // @@ -115,7 +115,7 @@ class edit_key extends XMLDBAction { $o.= ' '; /// XMLDB key comment $o.= ' '; - /// 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), @@ -126,13 +126,13 @@ class edit_key extends XMLDBAction { /// } $o.= ' '; $o.= ' ' . choose_from_menu($typeoptions, 'type', $key->getType(), '', '', '', true) . ''; - /// XMLDBKey Fields + /// xmldb_key Fields $o.= ' '; $o.= ' '; - /// XMLDBKey Reftable + /// xmldb_key Reftable $o.= ' '; $o.= ' '; - /// XMLDBKey Reffields + /// xmldb_key Reffields $o.= ' '; $o.= ' '; /// Change button diff --git a/admin/xmldb/actions/edit_key_save/edit_key_save.class.php b/admin/xmldb/actions/edit_key_save/edit_key_save.class.php index 09dcc8769b..3f3ef0af31 100644 --- a/admin/xmldb/actions/edit_key_save/edit_key_save.class.php +++ b/admin/xmldb/actions/edit_key_save/edit_key_save.class.php @@ -7,7 +7,7 @@ // 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 // @@ -230,7 +230,7 @@ class edit_key_save extends XMLDBAction { if (!empty($errors)) { - $tempkey = new XMLDBKey($name); + $tempkey = new xmldb_key($name); $tempkey->setType($type); $tempkey->setFields($fieldsarr); if ($type == XMLDB_KEY_FOREIGN || diff --git a/admin/xmldb/actions/edit_statement/edit_statement.class.php b/admin/xmldb/actions/edit_statement/edit_statement.class.php index 1e2a5faf79..f1c386461c 100644 --- a/admin/xmldb/actions/edit_statement/edit_statement.class.php +++ b/admin/xmldb/actions/edit_statement/edit_statement.class.php @@ -7,7 +7,7 @@ // 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 // @@ -89,7 +89,7 @@ class edit_statement extends XMLDBAction { 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)) { diff --git a/admin/xmldb/actions/edit_table_save/edit_table_save.class.php b/admin/xmldb/actions/edit_table_save/edit_table_save.class.php index 2f0d93b61b..329ca3d02a 100644 --- a/admin/xmldb/actions/edit_table_save/edit_table_save.class.php +++ b/admin/xmldb/actions/edit_table_save/edit_table_save.class.php @@ -7,7 +7,7 @@ // 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 // @@ -99,7 +99,7 @@ class edit_table_save extends XMLDBAction { } if (!empty($errors)) { - $temptable = new XMLDBTable($name); + $temptable = new xmldb_table($name); /// Prepare the output $site = get_site(); $navlinks = array(); diff --git a/admin/xmldb/actions/new_field/new_field.class.php b/admin/xmldb/actions/new_field/new_field.class.php index cbdd499abc..5203481ec1 100644 --- a/admin/xmldb/actions/new_field/new_field.class.php +++ b/admin/xmldb/actions/new_field/new_field.class.php @@ -7,7 +7,7 @@ // 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 // @@ -88,7 +88,7 @@ class new_field extends XMLDBAction { } } 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 diff --git a/admin/xmldb/actions/new_index/new_index.class.php b/admin/xmldb/actions/new_index/new_index.class.php index 5bf99c3b41..559d328ee3 100644 --- a/admin/xmldb/actions/new_index/new_index.class.php +++ b/admin/xmldb/actions/new_index/new_index.class.php @@ -7,7 +7,7 @@ // 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 // @@ -88,7 +88,7 @@ class new_index extends XMLDBAction { } } 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 diff --git a/admin/xmldb/actions/new_key/new_key.class.php b/admin/xmldb/actions/new_key/new_key.class.php index 0ecec1d7e2..78a57ae1bb 100644 --- a/admin/xmldb/actions/new_key/new_key.class.php +++ b/admin/xmldb/actions/new_key/new_key.class.php @@ -7,7 +7,7 @@ // 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 // @@ -88,7 +88,7 @@ class new_key extends XMLDBAction { } } 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 diff --git a/admin/xmldb/actions/new_statement/new_statement.class.php b/admin/xmldb/actions/new_statement/new_statement.class.php index c661cf0cea..6aaab2fb2c 100644 --- a/admin/xmldb/actions/new_statement/new_statement.class.php +++ b/admin/xmldb/actions/new_statement/new_statement.class.php @@ -7,7 +7,7 @@ // 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 // @@ -88,10 +88,10 @@ class new_statement extends XMLDBAction { /// 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; @@ -126,7 +126,7 @@ class new_statement extends XMLDBAction { } /// 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 @@ -135,8 +135,8 @@ class new_statement extends XMLDBAction { 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); diff --git a/admin/xmldb/actions/new_table/new_table.class.php b/admin/xmldb/actions/new_table/new_table.class.php index 424c46502c..4aae8e5b53 100644 --- a/admin/xmldb/actions/new_table/new_table.class.php +++ b/admin/xmldb/actions/new_table/new_table.class.php @@ -7,7 +7,7 @@ // 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 // @@ -84,7 +84,7 @@ class new_table extends XMLDBAction { } } 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); @@ -93,13 +93,13 @@ class new_table extends XMLDBAction { $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); diff --git a/admin/xmldb/actions/new_table_from_mysql/new_table_from_mysql.class.php b/admin/xmldb/actions/new_table_from_mysql/new_table_from_mysql.class.php index 3a2a3be408..4721818d10 100644 --- a/admin/xmldb/actions/new_table_from_mysql/new_table_from_mysql.class.php +++ b/admin/xmldb/actions/new_table_from_mysql/new_table_from_mysql.class.php @@ -7,7 +7,7 @@ // 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 // @@ -25,7 +25,7 @@ /////////////////////////////////////////////////////////////////////////// /// 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 { @@ -127,15 +127,15 @@ 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 @@ -149,9 +149,9 @@ class new_table_from_mysql extends XMLDBAction { 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 @@ -160,9 +160,9 @@ class new_table_from_mysql extends XMLDBAction { /// 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 diff --git a/admin/xmldb/actions/test/test.class.php b/admin/xmldb/actions/test/test.class.php index 4ed1d7251f..09c371724a 100644 --- a/admin/xmldb/actions/test/test.class.php +++ b/admin/xmldb/actions/test/test.class.php @@ -73,21 +73,21 @@ class test extends XMLDBAction { $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'); @@ -139,7 +139,7 @@ class test extends XMLDBAction { /// 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'); @@ -175,7 +175,7 @@ class test extends XMLDBAction { /// 4th test. Adding one complex enum field if ($test->status) { /// Create a new field with complex specs (enums are good candidates) - $field = new 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; @@ -202,7 +202,7 @@ class test extends XMLDBAction { /// 6th test. Adding one complex enum field if ($test->status) { /// Create a new field with complex specs (enums are good candidates) - $field = new 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; @@ -217,7 +217,7 @@ class test extends XMLDBAction { /// 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; @@ -232,7 +232,7 @@ class test extends XMLDBAction { /// 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); @@ -246,7 +246,7 @@ class test extends XMLDBAction { 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); @@ -261,7 +261,7 @@ class test extends XMLDBAction { 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); @@ -276,7 +276,7 @@ class test extends XMLDBAction { 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); @@ -291,7 +291,7 @@ class test extends XMLDBAction { 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); @@ -306,7 +306,7 @@ class test extends XMLDBAction { 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); @@ -321,7 +321,7 @@ class test extends XMLDBAction { 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); @@ -337,7 +337,7 @@ class test extends XMLDBAction { 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); @@ -352,7 +352,7 @@ class test extends XMLDBAction { 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); @@ -367,7 +367,7 @@ class test extends XMLDBAction { 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); @@ -382,7 +382,7 @@ class test extends XMLDBAction { 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); @@ -397,7 +397,7 @@ class test extends XMLDBAction { 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); @@ -412,7 +412,7 @@ class test extends XMLDBAction { 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); @@ -427,7 +427,7 @@ class test extends XMLDBAction { 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); @@ -442,7 +442,7 @@ class test extends XMLDBAction { 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); @@ -457,7 +457,7 @@ class test extends XMLDBAction { 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); @@ -472,7 +472,7 @@ class test extends XMLDBAction { 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); @@ -487,7 +487,7 @@ class test extends XMLDBAction { 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); @@ -503,7 +503,7 @@ class test extends XMLDBAction { 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); @@ -518,7 +518,7 @@ class test extends XMLDBAction { 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); @@ -533,7 +533,7 @@ class test extends XMLDBAction { 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); @@ -548,7 +548,7 @@ class test extends XMLDBAction { 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)) { @@ -567,7 +567,7 @@ class test extends XMLDBAction { 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); @@ -582,7 +582,7 @@ class test extends XMLDBAction { 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); @@ -597,7 +597,7 @@ class test extends XMLDBAction { 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); @@ -612,7 +612,7 @@ class test extends XMLDBAction { 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); @@ -627,7 +627,7 @@ class test extends XMLDBAction { 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); @@ -642,7 +642,7 @@ class test extends XMLDBAction { 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); @@ -656,7 +656,7 @@ class test extends XMLDBAction { /// 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; @@ -673,7 +673,7 @@ class test extends XMLDBAction { 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); @@ -687,7 +687,7 @@ class test extends XMLDBAction { 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); @@ -701,7 +701,7 @@ class test extends XMLDBAction { 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); @@ -717,7 +717,7 @@ class test extends XMLDBAction { 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); @@ -739,7 +739,7 @@ class test extends XMLDBAction { 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); @@ -767,7 +767,7 @@ class test extends XMLDBAction { 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; @@ -789,7 +789,7 @@ class test extends XMLDBAction { 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; @@ -805,7 +805,7 @@ class test extends XMLDBAction { 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; diff --git a/admin/xmldb/actions/view_structure_php/view_structure_php.class.php b/admin/xmldb/actions/view_structure_php/view_structure_php.class.php index cc7af7719c..92aefe6a46 100644 --- a/admin/xmldb/actions/view_structure_php/view_structure_php.class.php +++ b/admin/xmldb/actions/view_structure_php/view_structure_php.class.php @@ -170,7 +170,7 @@ class view_structure_php extends XMLDBAction { /// 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 @@ -248,7 +248,7 @@ class view_structure_php extends XMLDBAction { /// 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; @@ -289,7 +289,7 @@ class view_structure_php extends XMLDBAction { /// 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; diff --git a/admin/xmldb/actions/view_table_php/view_table_php.class.php b/admin/xmldb/actions/view_table_php/view_table_php.class.php index 22ca9f4b36..3725961d5a 100644 --- a/admin/xmldb/actions/view_table_php/view_table_php.class.php +++ b/admin/xmldb/actions/view_table_php/view_table_php.class.php @@ -330,8 +330,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -377,8 +377,8 @@ class view_table_php extends XMLDBAction { /// 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; @@ -423,8 +423,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -479,8 +479,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -532,8 +532,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -581,8 +581,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -630,8 +630,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -680,8 +680,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -729,8 +729,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -776,8 +776,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -823,8 +823,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -873,8 +873,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -920,8 +920,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -967,8 +967,8 @@ class view_table_php extends XMLDBAction { /// 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 @@ -1017,8 +1017,8 @@ class view_table_php extends XMLDBAction { /// 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 diff --git a/admin/xmldb/index.php b/admin/xmldb/index.php index f36ed99512..546d4323e3 100644 --- a/admin/xmldb/index.php +++ b/admin/xmldb/index.php @@ -38,11 +38,11 @@ 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 diff --git a/blocks/db/upgrade.php b/blocks/db/upgrade.php index a92117124b..f49995ee68 100644 --- a/blocks/db/upgrade.php +++ b/blocks/db/upgrade.php @@ -35,8 +35,8 @@ function xmldb_blocks_upgrade($oldversion=0) { 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 diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index f3a8e41527..4472450589 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -32,16 +32,16 @@ function xmldb_main_upgrade($oldversion=0) { 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 @@ -53,7 +53,7 @@ function xmldb_main_upgrade($oldversion=0) { 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); } @@ -95,8 +95,8 @@ function xmldb_main_upgrade($oldversion=0) { } /// 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 @@ -105,15 +105,15 @@ function xmldb_main_upgrade($oldversion=0) { } /// 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); diff --git a/lib/ddl/database_manager.php b/lib/ddl/database_manager.php index ac08932187..cb0d9ec7f5 100644 --- a/lib/ddl/database_manager.php +++ b/lib/ddl/database_manager.php @@ -90,9 +90,9 @@ class database_manager { } /** - * 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) { @@ -117,10 +117,10 @@ class database_manager { } /** - * 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) { @@ -162,11 +162,11 @@ class database_manager { } /** - * 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) { @@ -210,10 +210,10 @@ class database_manager { } /** - * 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) { @@ -221,14 +221,14 @@ class database_manager { } /** - * 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) { @@ -263,11 +263,11 @@ class database_manager { } /** - * 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) { @@ -278,19 +278,19 @@ class database_manager { * 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; } @@ -332,14 +332,14 @@ class database_manager { /** - * 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; } @@ -407,13 +407,13 @@ class database_manager { * 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; } @@ -479,13 +479,13 @@ class database_manager { * 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; } @@ -515,13 +515,13 @@ class database_manager { * 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; } @@ -548,14 +548,14 @@ class database_manager { * 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; } @@ -567,7 +567,7 @@ class database_manager { 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)) { @@ -602,19 +602,19 @@ class database_manager { * 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; } @@ -644,19 +644,19 @@ class database_manager { * 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; } @@ -679,19 +679,19 @@ class database_manager { * 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; } @@ -714,8 +714,8 @@ class database_manager { * 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 @@ -730,8 +730,8 @@ class database_manager { * 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 @@ -746,8 +746,8 @@ class database_manager { * 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 @@ -761,19 +761,19 @@ class database_manager { /** * 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; } @@ -812,19 +812,19 @@ class database_manager { * 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; } @@ -848,20 +848,20 @@ class database_manager { * 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; } @@ -917,19 +917,19 @@ class database_manager { * 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; } @@ -950,19 +950,19 @@ class database_manager { * 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; } @@ -984,8 +984,8 @@ class database_manager { * 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) @@ -994,12 +994,12 @@ class database_manager { 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; } @@ -1024,19 +1024,19 @@ class database_manager { * 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; } @@ -1060,19 +1060,19 @@ class database_manager { * 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; } @@ -1097,8 +1097,8 @@ class database_manager { * 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) @@ -1107,12 +1107,12 @@ class database_manager { 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; } diff --git a/lib/ddl/mssql_sql_generator.php b/lib/ddl/mssql_sql_generator.php index 402157f2e6..7cac0db09c 100644 --- a/lib/ddl/mssql_sql_generator.php +++ b/lib/ddl/mssql_sql_generator.php @@ -90,13 +90,13 @@ class mssql_sql_generator extends sql_generator { * 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; } @@ -198,7 +198,7 @@ class mssql_sql_generator extends sql_generator { } /** - * 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 */ @@ -229,7 +229,7 @@ class mssql_sql_generator extends sql_generator { } /** - * 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 @@ -289,7 +289,7 @@ class mssql_sql_generator extends sql_generator { $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); @@ -314,7 +314,7 @@ class mssql_sql_generator extends sql_generator { } /** - * 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) { @@ -373,7 +373,7 @@ class mssql_sql_generator extends sql_generator { } /** - * 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 @@ -397,7 +397,7 @@ class mssql_sql_generator extends sql_generator { } /** - * 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) { @@ -407,7 +407,7 @@ class mssql_sql_generator extends sql_generator { } /** - * 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) { @@ -424,7 +424,7 @@ class mssql_sql_generator extends sql_generator { } /** - * 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) { @@ -448,7 +448,7 @@ class mssql_sql_generator extends sql_generator { } /** - * 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) { @@ -469,7 +469,7 @@ class mssql_sql_generator extends sql_generator { } /** - * 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 */ @@ -491,7 +491,7 @@ class mssql_sql_generator extends sql_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. diff --git a/lib/ddl/mysql_sql_generator.php b/lib/ddl/mysql_sql_generator.php index a12721c7d2..a1e37ed4a4 100644 --- a/lib/ddl/mysql_sql_generator.php +++ b/lib/ddl/mysql_sql_generator.php @@ -166,7 +166,7 @@ class mysql_sql_generator extends sql_generator { } /** - * 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) { @@ -175,7 +175,7 @@ class mysql_sql_generator extends sql_generator { } /** - * 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) { @@ -184,7 +184,7 @@ class mysql_sql_generator extends sql_generator { } /** - * 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) { @@ -194,7 +194,7 @@ class mysql_sql_generator extends sql_generator { } /** - * 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 */ @@ -214,7 +214,7 @@ class mysql_sql_generator extends sql_generator { } /** - * 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) { @@ -244,7 +244,7 @@ class mysql_sql_generator extends sql_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. @@ -306,7 +306,7 @@ class mysql_sql_generator extends sql_generator { 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) { diff --git a/lib/ddl/oracle_sql_generator.php b/lib/ddl/oracle_sql_generator.php index 27a2536528..02d07be6a7 100644 --- a/lib/ddl/oracle_sql_generator.php +++ b/lib/ddl/oracle_sql_generator.php @@ -124,13 +124,13 @@ class oracle_sql_generator extends sql_generator { * 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; } @@ -266,7 +266,7 @@ class oracle_sql_generator extends sql_generator { * 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); } @@ -277,7 +277,7 @@ class oracle_sql_generator extends sql_generator { $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'); @@ -291,7 +291,7 @@ class oracle_sql_generator extends sql_generator { /// 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)); @@ -319,7 +319,7 @@ class oracle_sql_generator extends sql_generator { } /** - * 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 @@ -478,7 +478,7 @@ class oracle_sql_generator extends sql_generator { } /** - * 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) { @@ -488,7 +488,7 @@ class oracle_sql_generator extends sql_generator { } /** - * 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) { @@ -505,7 +505,7 @@ class oracle_sql_generator extends sql_generator { } /** - * 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) { @@ -515,7 +515,7 @@ class oracle_sql_generator extends sql_generator { } /** - * 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) { @@ -525,7 +525,7 @@ class oracle_sql_generator extends sql_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. @@ -567,7 +567,7 @@ class oracle_sql_generator extends sql_generator { } /** - * 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 @@ -595,7 +595,7 @@ class oracle_sql_generator extends sql_generator { } /** - * 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 */ diff --git a/lib/ddl/postgres_sql_generator.php b/lib/ddl/postgres_sql_generator.php index 1b75a8bbf9..77890f6769 100644 --- a/lib/ddl/postgres_sql_generator.php +++ b/lib/ddl/postgres_sql_generator.php @@ -144,9 +144,9 @@ class postgres_sql_generator extends sql_generator { $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'; @@ -177,7 +177,7 @@ class postgres_sql_generator extends sql_generator { } /** - * 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. * @@ -227,7 +227,7 @@ class postgres_sql_generator extends sql_generator { } /** - * 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 @@ -388,7 +388,7 @@ class postgres_sql_generator extends sql_generator { } /** - * 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) { @@ -398,7 +398,7 @@ class postgres_sql_generator extends sql_generator { } /** - * 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) { @@ -415,7 +415,7 @@ class postgres_sql_generator extends sql_generator { } /** - * 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) { @@ -425,7 +425,7 @@ class postgres_sql_generator extends sql_generator { } /** - * 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) { @@ -435,7 +435,7 @@ class postgres_sql_generator extends sql_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. @@ -483,7 +483,7 @@ class postgres_sql_generator extends sql_generator { } /** - * 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 diff --git a/lib/ddl/simpletest/testddllib.php b/lib/ddl/simpletest/testddllib.php index 53963f8399..7893616f3c 100755 --- a/lib/ddl/simpletest/testddllib.php +++ b/lib/ddl/simpletest/testddllib.php @@ -20,11 +20,11 @@ class ddllib_test extends UnitTestCase { 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, @@ -57,7 +57,7 @@ class ddllib_test extends UnitTestCase { $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'); @@ -83,11 +83,11 @@ class ddllib_test extends UnitTestCase { } 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); @@ -105,7 +105,7 @@ class ddllib_test extends UnitTestCase { 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)); @@ -117,7 +117,7 @@ class ddllib_test extends UnitTestCase { 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')); @@ -136,122 +136,122 @@ class ddllib_test extends UnitTestCase { 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); @@ -261,21 +261,21 @@ class ddllib_test extends UnitTestCase { 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); @@ -284,14 +284,14 @@ class ddllib_test extends UnitTestCase { 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); @@ -301,14 +301,14 @@ class ddllib_test extends UnitTestCase { 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)); @@ -316,7 +316,7 @@ class ddllib_test extends UnitTestCase { 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')); @@ -324,7 +324,7 @@ class ddllib_test extends UnitTestCase { 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')); @@ -333,7 +333,7 @@ class ddllib_test extends UnitTestCase { 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'); @@ -354,7 +354,7 @@ class ddllib_test extends UnitTestCase { $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)); } @@ -375,11 +375,11 @@ class ddllib_test extends UnitTestCase { $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 @@ -419,7 +419,7 @@ class ddllib_test extends UnitTestCase { $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 diff --git a/lib/ddl/sql_generator.php b/lib/ddl/sql_generator.php index 6d48b6d4f7..3ce38c11fb 100644 --- a/lib/ddl/sql_generator.php +++ b/lib/ddl/sql_generator.php @@ -198,9 +198,9 @@ abstract class sql_generator { } /** - * 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 */ @@ -217,7 +217,7 @@ abstract class sql_generator { } /** - * 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) { @@ -294,7 +294,7 @@ abstract class sql_generator { /// 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)) { @@ -338,7 +338,7 @@ abstract class sql_generator { } /** - * 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) { @@ -359,7 +359,7 @@ abstract class sql_generator { } /** - * 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) { @@ -443,7 +443,7 @@ abstract class sql_generator { } /** - * Given one correct XMLDBKey, returns its specs + * Given one correct xmldb_key, returns its specs */ public function getKeySQL($xmldb_table, $xmldb_key) { @@ -481,7 +481,7 @@ abstract class sql_generator { } /** - * 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) { @@ -515,7 +515,7 @@ abstract class sql_generator { } /** - * 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) { @@ -529,14 +529,14 @@ abstract class sql_generator { } /** - * 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); @@ -551,7 +551,7 @@ abstract class sql_generator { } /** - * 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) { @@ -570,7 +570,7 @@ abstract class sql_generator { } /** - * 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) { @@ -606,7 +606,7 @@ abstract class sql_generator { } /** - * 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) { @@ -623,7 +623,7 @@ abstract class sql_generator { } /** - * 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) { @@ -657,7 +657,7 @@ abstract class sql_generator { } /** - * 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) { @@ -678,7 +678,7 @@ abstract class sql_generator { } /** - * 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) { @@ -699,7 +699,7 @@ abstract class sql_generator { } /** - * 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) { @@ -731,7 +731,7 @@ abstract class sql_generator { } /** - * 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) { @@ -754,7 +754,7 @@ abstract class sql_generator { } 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)); @@ -773,7 +773,7 @@ abstract class sql_generator { } /** - * 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) { @@ -822,7 +822,7 @@ abstract class sql_generator { /// automatically by the RDBMS) drop the underlying (created by us) index (if exists) if (!$dropkey || $xmldb_key->getType() == XMLDB_KEY_FOREIGN) { /// Only if they exist - $xmldb_index = new 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)); @@ -841,7 +841,7 @@ abstract class sql_generator { } /** - * 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! */ @@ -858,7 +858,7 @@ abstract class sql_generator { ($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); } @@ -878,7 +878,7 @@ abstract class sql_generator { } /** - * 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) { @@ -887,7 +887,7 @@ abstract class sql_generator { } /** - * 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) { @@ -906,7 +906,7 @@ abstract class sql_generator { } /** - * 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) { @@ -1108,7 +1108,7 @@ abstract class sql_generator { /** * 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 */ @@ -1174,32 +1174,32 @@ abstract class sql_generator { } /** - * 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); diff --git a/lib/ddllib.php b/lib/ddllib.php index 01487124cd..fa21674afd 100644 --- a/lib/ddllib.php +++ b/lib/ddllib.php @@ -45,11 +45,11 @@ require_once($CFG->libdir.'/xmldb/xmldb_constants.php'); 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'); @@ -81,7 +81,7 @@ function drop_plugin_tables($name, $file, $feedback=true) { // 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); } } diff --git a/lib/dml/oci8po_adodb_moodle_database.php b/lib/dml/oci8po_adodb_moodle_database.php index 86990037f1..38f7565915 100644 --- a/lib/dml/oci8po_adodb_moodle_database.php +++ b/lib/dml/oci8po_adodb_moodle_database.php @@ -397,7 +397,7 @@ error('todo'); 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 diff --git a/lib/simpletest/fixtures/gradetest.php b/lib/simpletest/fixtures/gradetest.php index bc752b8f1a..0fc187af39 100644 --- a/lib/simpletest/fixtures/gradetest.php +++ b/lib/simpletest/fixtures/gradetest.php @@ -118,7 +118,7 @@ class grade_test extends UnitTestCase { $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 @@ -155,7 +155,7 @@ class grade_test extends UnitTestCase { } /// Define table modules to be created - $table = new XMLDBTable('modules'); + $table = new xmldb_table('modules'); if (!table_exists($table)) { @@ -181,7 +181,7 @@ class grade_test extends UnitTestCase { } /// 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); @@ -229,7 +229,7 @@ class grade_test extends UnitTestCase { /// Define table grade_categories to be created - $table = new XMLDBTable('grade_categories'); + $table = new xmldb_table('grade_categories'); if ($result && !table_exists($table)) { @@ -261,7 +261,7 @@ class grade_test extends UnitTestCase { /// Define table grade_grades to be created - $table = new XMLDBTable('grade_grades'); + $table = new xmldb_table('grade_grades'); if ($result && !table_exists($table)) { @@ -302,7 +302,7 @@ class grade_test extends UnitTestCase { /// Define table grade_outcomes to be created - $table = new XMLDBTable('grade_outcomes'); + $table = new xmldb_table('grade_outcomes'); if ($result && !table_exists($table)) { @@ -331,7 +331,7 @@ class grade_test extends UnitTestCase { /// Define table scale to be created - $table = new XMLDBTable('scale'); + $table = new xmldb_table('scale'); if ($result && !table_exists($table)) { @@ -353,7 +353,7 @@ class grade_test extends UnitTestCase { } /// 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 @@ -405,7 +405,7 @@ class grade_test extends UnitTestCase { $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)) { @@ -461,7 +461,7 @@ class grade_test extends UnitTestCase { } /// 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)) { @@ -503,7 +503,7 @@ class grade_test extends UnitTestCase { /// 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)) { @@ -554,7 +554,7 @@ class grade_test extends UnitTestCase { /// 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)) { @@ -588,7 +588,7 @@ class grade_test extends UnitTestCase { } /// Define table scale to be created - $table = new XMLDBTable('scale_history'); + $table = new xmldb_table('scale_history'); if ($result && !table_exists($table)) { diff --git a/lib/xmldb/XMLDBField.class.php b/lib/xmldb/xmldb_field.php similarity index 97% rename from lib/xmldb/XMLDBField.class.php rename to lib/xmldb/xmldb_field.php index f542af0cb9..bc57f58df7 100644 --- a/lib/xmldb/XMLDBField.class.php +++ b/lib/xmldb/xmldb_field.php @@ -7,7 +7,7 @@ // 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 // @@ -26,7 +26,18 @@ /// 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; @@ -39,9 +50,9 @@ class XMLDBField extends xmldb_object { 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; @@ -55,7 +66,7 @@ class XMLDBField extends xmldb_object { } /** - * 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 @@ -243,7 +254,7 @@ class XMLDBField extends xmldb_object { /** * Load data from XML to the table */ - function arr2XMLDBField($xmlarr) { + function arr2xmldb_field($xmlarr) { $result = true; @@ -534,7 +545,7 @@ class XMLDBField extends xmldb_object { } /** - * 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) { @@ -617,7 +628,7 @@ class XMLDBField extends xmldb_object { } /** - * 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) { @@ -744,7 +755,7 @@ class XMLDBField extends xmldb_object { } /** - * Returns the PHP code needed to define one XMLDBField + * Returns the PHP code needed to define one xmldb_field */ function getPHP($includeprevious=true) { diff --git a/lib/xmldb/xmldb_file.php b/lib/xmldb/xmldb_file.php index 119297980d..efda14f965 100644 --- a/lib/xmldb/xmldb_file.php +++ b/lib/xmldb/xmldb_file.php @@ -36,7 +36,7 @@ class xmldb_file extends xmldb_object { /** * Constructor of the xmldb_file */ - function __construct ($path) { + function __construct($path) { parent::__construct($path); $this->path = $path; $this->xmldb_structure = NULL; diff --git a/lib/xmldb/XMLDBIndex.class.php b/lib/xmldb/xmldb_index.php similarity index 91% rename from lib/xmldb/XMLDBIndex.class.php rename to lib/xmldb/xmldb_index.php index 49b79a1f77..0c1577f66e 100644 --- a/lib/xmldb/XMLDBIndex.class.php +++ b/lib/xmldb/xmldb_index.php @@ -7,7 +7,7 @@ // 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 // @@ -26,22 +26,33 @@ /// 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 @@ -82,7 +93,7 @@ class XMLDBIndex extends xmldb_object { /** * Load data from XML to the index */ - function arr2XMLDBIndex($xmlarr) { + function arr2xmldb_index($xmlarr) { $result = true; @@ -164,7 +175,7 @@ class XMLDBIndex extends xmldb_object { } /** - * 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) { @@ -203,7 +214,7 @@ class XMLDBIndex extends xmldb_object { } /** - * 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) { @@ -219,7 +230,7 @@ class XMLDBIndex extends xmldb_object { } /** - * Returns the PHP code needed to define one XMLDBIndex + * Returns the PHP code needed to define one xmldb_index */ function getPHP() { diff --git a/lib/xmldb/XMLDBKey.class.php b/lib/xmldb/xmldb_key.php similarity index 95% rename from lib/xmldb/XMLDBKey.class.php rename to lib/xmldb/xmldb_key.php index 16ee858046..00a5ca939d 100644 --- a/lib/xmldb/XMLDBKey.class.php +++ b/lib/xmldb/xmldb_key.php @@ -7,7 +7,7 @@ // 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 // @@ -26,7 +26,18 @@ /// 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; @@ -34,9 +45,9 @@ class XMLDBKey extends xmldb_object { 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(); @@ -45,7 +56,7 @@ class XMLDBKey extends xmldb_object { } /** - * 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 @@ -118,7 +129,7 @@ class XMLDBKey extends xmldb_object { /** * Load data from XML to the key */ - function arr2XMLDBKey($xmlarr) { + function arr2xmldb_key($xmlarr) { $result = true; @@ -323,7 +334,7 @@ class XMLDBKey extends xmldb_object { } /** - * 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) { @@ -367,7 +378,7 @@ class XMLDBKey extends xmldb_object { } /** - * 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) { @@ -389,7 +400,7 @@ class XMLDBKey extends xmldb_object { } /** - * Returns the PHP code needed to define one XMLDBKey + * Returns the PHP code needed to define one xmldb_key */ function getPHP() { diff --git a/lib/xmldb/XMLDBStatement.class.php b/lib/xmldb/xmldb_statement.php similarity index 94% rename from lib/xmldb/XMLDBStatement.class.php rename to lib/xmldb/xmldb_statement.php index 0b51668c1d..80587851bc 100644 --- a/lib/xmldb/XMLDBStatement.class.php +++ b/lib/xmldb/xmldb_statement.php @@ -7,7 +7,7 @@ // 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 // @@ -28,16 +28,27 @@ /// (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; @@ -89,7 +100,7 @@ class XMLDBStatement extends xmldb_object { /** * Load data from XML to the index */ - function arr2XMLDBStatement($xmlarr) { + function arr2xmldb_statement($xmlarr) { $result = true; @@ -255,7 +266,7 @@ class XMLDBStatement extends xmldb_object { } /** - * 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) { @@ -271,7 +282,7 @@ class XMLDBStatement extends xmldb_object { */ function xmlOutput() { $o = ''; - $o.= ' name . '" TYPE="' . xmldb_statement::getXMLDBStatementName($this->type) . '" TABLE="' . $this->table . '"'; if ($this->comment) { $o.= ' COMMENT="' . htmlspecialchars($this->comment) . '"'; } @@ -297,7 +308,7 @@ class XMLDBStatement extends xmldb_object { } /** - * 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) { diff --git a/lib/xmldb/xmldb_structure.php b/lib/xmldb/xmldb_structure.php index 01b8d12786..481cc528d1 100644 --- a/lib/xmldb/xmldb_structure.php +++ b/lib/xmldb/xmldb_structure.php @@ -36,7 +36,7 @@ class xmldb_structure extends xmldb_object { /** * Creates one new xmldb_structure */ - function construct($name) { + function __construct($name) { parent::__construct($name); $this->path = NULL; $this->version = NULL; @@ -59,7 +59,7 @@ class xmldb_structure extends xmldb_object { } /** - * Returns one XMLDBTable + * Returns one xmldb_table */ function &getTable($tablename) { $i = $this->findTableInArray($tablename); @@ -130,7 +130,7 @@ class xmldb_structure extends xmldb_object { } /** - * Returns one XMLDBStatement + * Returns one xmldb_statement */ function &getStatement($statementname) { $i = $this->findStatementInArray($statementname); @@ -371,8 +371,8 @@ class xmldb_structure extends xmldb_object { 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; @@ -416,8 +416,8 @@ class xmldb_structure extends xmldb_object { 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; diff --git a/lib/xmldb/XMLDBTable.class.php b/lib/xmldb/xmldb_table.php similarity index 96% rename from lib/xmldb/XMLDBTable.class.php rename to lib/xmldb/xmldb_table.php index f0c27497ec..1cdad4bd8e 100644 --- a/lib/xmldb/XMLDBTable.class.php +++ b/lib/xmldb/xmldb_table.php @@ -7,7 +7,7 @@ // 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 // @@ -26,16 +26,27 @@ /// 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(); @@ -202,7 +213,7 @@ class XMLDBTable extends xmldb_object { } /** - * Returns one XMLDBField + * Returns one xmldb_field */ function &getField($fieldname) { $i = $this->findFieldInArray($fieldname); @@ -240,7 +251,7 @@ class XMLDBTable extends xmldb_object { } /** - * Returns one XMLDBKey + * Returns one xmldb_key */ function &getKey($keyname) { $i = $this->findKeyInArray($keyname); @@ -278,7 +289,7 @@ class XMLDBTable extends xmldb_object { } /** - * Returns one XMLDBIndex + * Returns one xmldb_index */ function &getIndex($indexname) { $i = $this->findIndexInArray($indexname); @@ -432,7 +443,7 @@ class XMLDBTable extends xmldb_object { /** * Load data from XML to the table */ - function arr2XMLDBTable($xmlarr) { + function arr2xmldb_table($xmlarr) { global $CFG; @@ -474,8 +485,8 @@ class XMLDBTable extends xmldb_object { 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; @@ -519,8 +530,8 @@ class XMLDBTable extends xmldb_object { 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; @@ -567,8 +578,8 @@ class XMLDBTable extends xmldb_object { 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; @@ -612,7 +623,7 @@ class XMLDBTable extends xmldb_object { } /** - * 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) { @@ -711,7 +722,7 @@ class XMLDBTable extends xmldb_object { * @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); @@ -729,7 +740,7 @@ class XMLDBTable extends xmldb_object { * @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); } @@ -743,7 +754,7 @@ class XMLDBTable extends xmldb_object { * @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); } diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php index 082293f592..f6f5b66aef 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -30,8 +30,8 @@ function xmldb_data_upgrade($oldversion=0) { 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)) { @@ -45,8 +45,8 @@ function xmldb_data_upgrade($oldversion=0) { $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); diff --git a/mod/feedback/db/upgrade.php b/mod/feedback/db/upgrade.php index b22924d618..cddad37de8 100644 --- a/mod/feedback/db/upgrade.php +++ b/mod/feedback/db/upgrade.php @@ -28,33 +28,33 @@ function xmldb_feedback_upgrade($oldversion=0) { 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); @@ -62,37 +62,37 @@ function xmldb_feedback_upgrade($oldversion=0) { //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //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); @@ -103,29 +103,29 @@ function xmldb_feedback_upgrade($oldversion=0) { 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); @@ -136,8 +136,8 @@ function xmldb_feedback_upgrade($oldversion=0) { 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); @@ -204,8 +204,8 @@ function xmldb_feedback_upgrade($oldversion=0) { 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); @@ -213,8 +213,8 @@ function xmldb_feedback_upgrade($oldversion=0) { 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); @@ -222,8 +222,8 @@ function xmldb_feedback_upgrade($oldversion=0) { 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; diff --git a/mod/lesson/db/upgrade.php b/mod/lesson/db/upgrade.php index 7c8366f3ac..d98f3a8b2e 100644 --- a/mod/lesson/db/upgrade.php +++ b/mod/lesson/db/upgrade.php @@ -29,9 +29,9 @@ function xmldb_lesson_upgrade($oldversion=0) { 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)) {