require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/blocklib.php');
require_once($CFG->libdir.'/tablelib.php');
- require_once($CFG->libdir.'/ddllib.php');
admin_externalpage_setup('manageblocks');
require_once(dirname(dirname(__FILE__)) . '/config.php');
require_once($CFG->libdir.'/adminlib.php'); // Contains various admin-only functions
- require_once($CFG->libdir.'/ddllib.php'); // Install/upgrade related db functions
/**
* @todo check upgrade status, if upgrader is running already, notify user and exit.
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php'); // Contains various admin-only functions
- require_once($CFG->libdir.'/ddllib.php'); // Install/upgrade related db functions
require_once($CFG->libdir.'/db/upgradelib.php'); // Upgrade-related functions
$id = optional_param('id', '', PARAM_TEXT);
require_once('../course/lib.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
- require_once($CFG->libdir.'/ddllib.php');
// defines
define('MODULE_TABLE','module_administration_table');
$dbman = $DB->get_manager();
$dbfamily = $DB->get_dbfamily();
- /// And we nedd some ddl suff
- require_once ($CFG->libdir . '/ddllib.php');
-
/// Here we'll acummulate all the wrong fields found
$wrong_fields = array();
global $CFG, $XMLDB, $DB;
/// And we nedd some ddl suff
- require_once ($CFG->libdir . '/ddllib.php');
$dbman = $DB->get_manager();
/// Here we'll acummulate all the wrong fields found
$dbman = $DB->get_manager();
- /// And we nedd some ddl suff
- require_once ($CFG->libdir . '/ddllib.php');
-
/// Here we'll acummulate all the missing indexes found
$missing_indexes = array();
/// getting "incomplete" objects
require_once('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
- require_once($CFG->libdir.'/ddllib.php'); // Install/upgrade related db functions
admin_externalpage_setup('xmldbeditor');
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_backup_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_activity_modules_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_admin_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_calendar_month_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_calendar_upcoming_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_course_list_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_course_summary_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_blocks_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
if ($result && $oldversion < 2007081300) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_news_items_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_online_users_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_participants_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_recent_activity_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_rss_client_upgrade($oldversion=0) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_search_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
//===== 1.9.0 upgrade line ======//
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_search_forums_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_section_links_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_block_social_activities_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_enrol_authorize_upgrade($oldversion=0) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_enrol_paypal_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
*/
function build_context_path($force=false) {
global $CFG, $DB;
- require_once($CFG->libdir.'/ddllib.php');
// System context
$sitectx = get_system_context(!$force);
* @package moodlecore
*/
+/// Add required XMLDB constants
+require_once($CFG->libdir.'/xmldb/xmldb_constants.php');
+
+/// Add required XMLDB DB classes
+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/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');
+
function upgrade_main_savepoint($result, $version) {
global $CFG;
//TODO
}
+/**
+ * Delete all plugin tables
+ * @name string name of plugin, used as table prefix
+ * @file string path to install.xml file
+ * @feedback boolean
+ */
+function drop_plugin_tables($name, $file, $feedback=true) {
+ global $CFG, $DB;
+
+ // first try normal delete
+ if ($DB->get_manager()->delete_tables_from_xmldb_file($file, $feedback)) {
+ return true;
+ }
+
+ // then try to find all tables that start with name and are not in any xml file
+ $used_tables = get_used_table_names();
+
+ $tables = $DB->get_tables();
+
+ /// Iterate over, fixing id fields as necessary
+ foreach ($tables as $table) {
+ if (in_array($table, $used_tables)) {
+ continue;
+ }
+
+ // found orphan table --> delete it
+ if ($DB->get_manager()->table_exists($table)) {
+ $xmldb_table = new xmldb_table($table);
+ $DB->get_manager()->drop_table($xmldb_table, true, $feedback);
+ }
+ }
+
+ return true;
+}
+
+/**
+ * Returns names of all known tables == tables that moodle knowns about.
+ * @return array of lowercase table names
+ */
+function get_used_table_names() {
+ $table_names = array();
+ $dbdirs = get_db_directories();
+
+ foreach ($dbdirs as $dbdir) {
+ $file = $dbdir.'/install.xml';
+
+ $xmldb_file = new xmldb_file($file);
+
+ if (!$xmldb_file->fileExists()) {
+ continue;
+ }
+
+ $loaded = $xmldb_file->loadXMLStructure();
+ $structure =& $xmldb_file->getStructure();
+
+ if ($loaded and $tables = $structure->getTables()) {
+ foreach($tables as $table) {
+ $table_names[] = strtolower($table->name);
+ }
+ }
+ }
+
+ return $table_names;
+}
+
+/**
+ * Returns list of all directories where we expect install.xml files
+ * @return array of paths
+ */
+function get_db_directories() {
+ global $CFG;
+
+ $dbdirs = array();
+
+/// First, the main one (lib/db)
+ $dbdirs[] = $CFG->libdir.'/db';
+
+/// Now, activity modules (mod/xxx/db)
+ if ($plugins = get_list_of_plugins('mod')) {
+ foreach ($plugins as $plugin) {
+ $dbdirs[] = $CFG->dirroot.'/mod/'.$plugin.'/db';
+ }
+ }
+
+/// Now, assignment submodules (mod/assignment/type/xxx/db)
+ if ($plugins = get_list_of_plugins('mod/assignment/type')) {
+ foreach ($plugins as $plugin) {
+ $dbdirs[] = $CFG->dirroot.'/mod/assignment/type/'.$plugin.'/db';
+ }
+ }
+
+/// Now, question types (question/type/xxx/db)
+ if ($plugins = get_list_of_plugins('question/type')) {
+ foreach ($plugins as $plugin) {
+ $dbdirs[] = $CFG->dirroot.'/question/type/'.$plugin.'/db';
+ }
+ }
+
+/// Now, backup/restore stuff (backup/db)
+ $dbdirs[] = $CFG->dirroot.'/backup/db';
+
+/// Now, block system stuff (blocks/db)
+ $dbdirs[] = $CFG->dirroot.'/blocks/db';
+
+/// Now, blocks (blocks/xxx/db)
+ if ($plugins = get_list_of_plugins('blocks', 'db')) {
+ foreach ($plugins as $plugin) {
+ $dbdirs[] = $CFG->dirroot.'/blocks/'.$plugin.'/db';
+ }
+ }
+
+/// Now, course formats (course/format/xxx/db)
+ if ($plugins = get_list_of_plugins('course/format', 'db')) {
+ foreach ($plugins as $plugin) {
+ $dbdirs[] = $CFG->dirroot.'/course/format/'.$plugin.'/db';
+ }
+ }
+
+/// Now, enrolment plugins (enrol/xxx/db)
+ if ($plugins = get_list_of_plugins('enrol', 'db')) {
+ foreach ($plugins as $plugin) {
+ $dbdirs[] = $CFG->dirroot.'/enrol/'.$plugin.'/db';
+ }
+ }
+
+/// Now admin report plugins (admin/report/xxx/db)
+ if ($plugins = get_list_of_plugins($CFG->admin.'/report', 'db')) {
+ foreach ($plugins as $plugin) {
+ $dbdirs[] = $CFG->dirroot.'/'.$CFG->admin.'/report/'.$plugin.'/db';
+ }
+ }
+
+/// Local database changes, if the local folder exists.
+ if (file_exists($CFG->dirroot . '/local')) {
+ $dbdirs[] = $CFG->dirroot.'/local/db';
+ }
+
+ return $dbdirs;
+}
+
/**
* Upgrade plugins
*
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_main_upgrade($oldversion=0) {
/**
* This function will execute an array of SQL commands, returning
* true/false if any error is found and stopping/continue as desired.
- * It's widely used by all the ddllib.php functions
*
* @param array $sqlarr array of sql statements to execute
* @param boolean $continue to specify if must continue on error (true) or stop (false)
$results = array(); //Array where all the sentences will be stored
- /// Although this is checked in ddllib - rename_field() - double check
+ /// Although this is checked in database_manager::rename_field() - double check
/// that we aren't trying to rename one "id" field. Although it could be
/// implemented (if adding the necessary code to rename sequences, defaults,
/// triggers... and so on under each getRenameFieldExtraSQL() function, it's
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
-require_once($CFG->libdir . '/ddllib.php');
+require_once($CFG->libdir . '/adminlib.php');
class ddllib_test extends UnitTestCase {
private $tables = array();
$results = array(); //Array where all the sentences will be stored
- /// Although this is checked in ddllib - rename_field() - double check
+ /// Although this is checked in database_manager::rename_field() - double check
/// that we aren't trying to rename one "id" field. Although it could be
/// implemented (if adding the necessary code to rename sequences, defaults,
/// triggers... and so on under each getRenameFieldExtraSQL() function, it's
//
// For further documentation, visit http://docs.moodle.org/en/DDL_functions
-/// Add required XMLDB constants
-require_once($CFG->libdir.'/xmldb/xmldb_constants.php');
-
-/// Add required XMLDB DB classes
-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/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');
-
-/**
- * Delete all plugin tables
- * @name string name of plugin, used as table prefix
- * @file string path to install.xml file
- * @feedback boolean
- */
-function drop_plugin_tables($name, $file, $feedback=true) {
- global $CFG, $DB;
-
- // first try normal delete
- if ($DB->get_manager()->delete_tables_from_xmldb_file($file, $feedback)) {
- return true;
- }
-
- // then try to find all tables that start with name and are not in any xml file
- $used_tables = get_used_table_names();
-
- $tables = $DB->get_tables();
-
- /// Iterate over, fixing id fields as necessary
- foreach ($tables as $table) {
- if (in_array($table, $used_tables)) {
- continue;
- }
-
- // found orphan table --> delete it
- if ($DB->get_manager()->table_exists($table)) {
- $xmldb_table = new xmldb_table($table);
- $DB->get_manager()->drop_table($xmldb_table, true, $feedback);
- }
- }
-
- return true;
-}
-
-/**
- * Returns names of all known tables == tables that moodle knowns about.
- * @return array of lowercase table names
- */
-function get_used_table_names() {
- $table_names = array();
- $dbdirs = get_db_directories();
-
- foreach ($dbdirs as $dbdir) {
- $file = $dbdir.'/install.xml';
-
- $xmldb_file = new xmldb_file($file);
-
- if (!$xmldb_file->fileExists()) {
- continue;
- }
-
- $loaded = $xmldb_file->loadXMLStructure();
- $structure =& $xmldb_file->getStructure();
-
- if ($loaded and $tables = $structure->getTables()) {
- foreach($tables as $table) {
- $table_names[] = strtolower($table->name);
- }
- }
- }
-
- return $table_names;
-}
-
-/**
- * Returns list of all directories where we expect install.xml files
- * @return array of paths
- */
-function get_db_directories() {
- global $CFG;
-
- $dbdirs = array();
-
-/// First, the main one (lib/db)
- $dbdirs[] = $CFG->libdir.'/db';
-
-/// Now, activity modules (mod/xxx/db)
- if ($plugins = get_list_of_plugins('mod')) {
- foreach ($plugins as $plugin) {
- $dbdirs[] = $CFG->dirroot.'/mod/'.$plugin.'/db';
- }
- }
-
-/// Now, assignment submodules (mod/assignment/type/xxx/db)
- if ($plugins = get_list_of_plugins('mod/assignment/type')) {
- foreach ($plugins as $plugin) {
- $dbdirs[] = $CFG->dirroot.'/mod/assignment/type/'.$plugin.'/db';
- }
- }
-
-/// Now, question types (question/type/xxx/db)
- if ($plugins = get_list_of_plugins('question/type')) {
- foreach ($plugins as $plugin) {
- $dbdirs[] = $CFG->dirroot.'/question/type/'.$plugin.'/db';
- }
- }
-
-/// Now, backup/restore stuff (backup/db)
- $dbdirs[] = $CFG->dirroot.'/backup/db';
-
-/// Now, block system stuff (blocks/db)
- $dbdirs[] = $CFG->dirroot.'/blocks/db';
-
-/// Now, blocks (blocks/xxx/db)
- if ($plugins = get_list_of_plugins('blocks', 'db')) {
- foreach ($plugins as $plugin) {
- $dbdirs[] = $CFG->dirroot.'/blocks/'.$plugin.'/db';
- }
- }
-
-/// Now, course formats (course/format/xxx/db)
- if ($plugins = get_list_of_plugins('course/format', 'db')) {
- foreach ($plugins as $plugin) {
- $dbdirs[] = $CFG->dirroot.'/course/format/'.$plugin.'/db';
- }
- }
-
-/// Now, enrolment plugins (enrol/xxx/db)
- if ($plugins = get_list_of_plugins('enrol', 'db')) {
- foreach ($plugins as $plugin) {
- $dbdirs[] = $CFG->dirroot.'/enrol/'.$plugin.'/db';
- }
- }
-
-/// Now admin report plugins (admin/report/xxx/db)
- if ($plugins = get_list_of_plugins($CFG->admin.'/report', 'db')) {
- foreach ($plugins as $plugin) {
- $dbdirs[] = $CFG->dirroot.'/'.$CFG->admin.'/report/'.$plugin.'/db';
- }
- }
-
-/// Local database changes, if the local folder exists.
- if (file_exists($CFG->dirroot . '/local')) {
- $dbdirs[] = $CFG->dirroot.'/local/db';
- }
-
- return $dbdirs;
-}
-
-
// DEPRECATED - to be removed soon
-function table_exists($table) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->table_exists($table);
-}
-
-function field_exists($table, $field) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->field_exists($table, $field);
-}
-
-function find_index_name($table, $index) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->find_index_name($table, $index);
-}
-
-function index_exists($table, $index) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->index_exists($table, $index);
-}
-
-function find_check_constraint_name($table, $field) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->find_check_constraint_name($table, $field);
-}
-
-function check_constraint_exists($table, $field) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->check_constraint_exists($table, $field);
-}
-
-function find_key_name($table, $xmldb_key) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->find_key_name($table, $xmldb_key);
-}
-
-function find_sequence_name($table) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->find_sequence_name($table);
-}
-
-function drop_table($table, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->drop_table($table, $continue, $feedback);
-}
-
-function install_from_xmldb_file($file) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->install_from_xmldb_file($file);
-}
-
-function create_table($table, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->create_table($table, $continue, $feedback);
-}
-
-function create_temp_table($table, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->create_temp_table($table, $continue, $feedback);
-}
-
-function rename_table($table, $newname, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->rename_table($table, $newname, $continue, $feedback);
-}
-
-function add_field($table, $field, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->add_field($table, $field, $continue, $feedback);
-}
-
-function drop_field($table, $field, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->drop_field($table, $field, $continue, $feedback);
-}
-
-function change_field_type($table, $field, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->change_field_type($table, $field, $continue, $feedback);
-}
-
-function change_field_precision($table, $field, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->change_field_precision($table, $field, $continue, $feedback);
-}
-
-function change_field_unsigned($table, $field, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->change_field_unsigned($table, $field, $continue, $feedback);
-}
-
-function change_field_notnull($table, $field, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->change_field_notnull($table, $field, $continue, $feedback);
-}
-
-function change_field_enum($table, $field, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->change_field_enum($table, $field, $continue, $feedback);
-}
-
-function change_field_default($table, $field, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->change_field_default($table, $field, $continue, $feedback);
-}
-
-function rename_field($table, $field, $newname, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->rename_field($table, $field, $continue, $feedback);
-}
-
-function add_key($table, $key, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->add_key($table, $key, $continue, $feedback);
-}
-
-function drop_key($table, $key, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->drop_key($table, $key, $continue, $feedback);
-}
-
-function rename_key($table, $key, $newname, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->rename_key($table, $key, $newname, $continue, $feedback);
-}
-
-function add_index($table, $index, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->add_index($table, $index, $continue, $feedback);
-}
-
-function drop_index($table, $index, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->drop_index($table, $index, $continue, $feedback);
-}
-
-function rename_index($table, $index, $newname, $continue=true, $feedback=true) {
- global $DB;
- debugging('Deprecated ddllib function used!');
- return $DB->get_manager()->rename_index($table, $index, $newname, $continue, $feedback);
-}
-
?>
}
+/// Deprecated DDL functions, to be removed soon ///
+
+function table_exists($table) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->table_exists($table);
+}
+
+function field_exists($table, $field) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->field_exists($table, $field);
+}
+
+function find_index_name($table, $index) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->find_index_name($table, $index);
+}
+
+function index_exists($table, $index) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->index_exists($table, $index);
+}
+
+function find_check_constraint_name($table, $field) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->find_check_constraint_name($table, $field);
+}
+
+function check_constraint_exists($table, $field) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->check_constraint_exists($table, $field);
+}
+
+function find_key_name($table, $xmldb_key) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->find_key_name($table, $xmldb_key);
+}
+
+function find_sequence_name($table) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->find_sequence_name($table);
+}
+
+function drop_table($table, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->drop_table($table, $continue, $feedback);
+}
+
+function install_from_xmldb_file($file) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->install_from_xmldb_file($file);
+}
+
+function create_table($table, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->create_table($table, $continue, $feedback);
+}
+
+function create_temp_table($table, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->create_temp_table($table, $continue, $feedback);
+}
+
+function rename_table($table, $newname, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->rename_table($table, $newname, $continue, $feedback);
+}
+
+function add_field($table, $field, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->add_field($table, $field, $continue, $feedback);
+}
+
+function drop_field($table, $field, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->drop_field($table, $field, $continue, $feedback);
+}
+
+function change_field_type($table, $field, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->change_field_type($table, $field, $continue, $feedback);
+}
+
+function change_field_precision($table, $field, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->change_field_precision($table, $field, $continue, $feedback);
+}
+
+function change_field_unsigned($table, $field, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->change_field_unsigned($table, $field, $continue, $feedback);
+}
+
+function change_field_notnull($table, $field, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->change_field_notnull($table, $field, $continue, $feedback);
+}
+
+function change_field_enum($table, $field, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->change_field_enum($table, $field, $continue, $feedback);
+}
+
+function change_field_default($table, $field, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->change_field_default($table, $field, $continue, $feedback);
+}
+
+function rename_field($table, $field, $newname, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->rename_field($table, $field, $continue, $feedback);
+}
+
+function add_key($table, $key, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->add_key($table, $key, $continue, $feedback);
+}
+
+function drop_key($table, $key, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->drop_key($table, $key, $continue, $feedback);
+}
+
+function rename_key($table, $key, $newname, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->rename_key($table, $key, $newname, $continue, $feedback);
+}
+
+function add_index($table, $index, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->add_index($table, $index, $continue, $feedback);
+}
+
+function drop_index($table, $index, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->drop_index($table, $index, $continue, $feedback);
+}
+
+function rename_index($table, $index, $newname, $continue=true, $feedback=true) {
+ global $DB;
+ debugging('Deprecated ddllib function used!');
+ return $DB->get_manager()->rename_index($table, $index, $newname, $continue, $feedback);
+}
+
//////////////////////////
/// removed functions ////
$signed='unsigned', $default='0', $null='not null', $after='') {
error('table_column() was removed, please use new ddl functions');
}
-
\ No newline at end of file
+
global $CFG;
if (!$this->database_manager) {
- require_once($CFG->libdir.'/ddllib.php');
+ require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/ddl/database_manager.php');
$classname = $this->get_dbfamily().'_sql_generator';
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodlecore
*/
+require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->libdir . '/gradelib.php');
-require_once($CFG->libdir . '/dmllib.php');
-require_once($CFG->libdir . '/ddllib.php');
Mock::generate('grade_item', 'mock_grade_item');
Mock::generate('grade_scale', 'mock_grade_scale');
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_assignment_upgrade($oldversion=0) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_chat_upgrade($oldversion=0) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_choice_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
//===== 1.9.0 upgrade line ======//
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_data_upgrade($oldversion=0) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_feedback_upgrade($oldversion=0) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_forum_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
//===== 1.9.0 upgrade line ======//
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_glossary_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
//===== 1.9.0 upgrade line ======//
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_label_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
//===== 1.9.0 upgrade line ======//
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_lesson_upgrade($oldversion=0) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_quiz_upgrade($oldversion=0) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_resource_upgrade($oldversion=0) {
global $CFG, $THEME, $DB;
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
//===== 1.9.0 upgrade line ======//
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_scorm_upgrade($oldversion=0) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_survey_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
//===== 1.9.0 upgrade line ======//
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_wiki_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
//===== 1.9.0 upgrade line ======//
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_qtype_calculated_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_qtype_essay_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_qtype_match_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_qtype_multianswer_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
if ($result && $oldversion < 2008050800) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_qtype_multichoice_upgrade($oldversion=0) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_qtype_numerical_upgrade($oldversion=0) {
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_qtype_randomsamatch_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_qtype_shortanswer_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
-// using the functions defined in lib/ddllib.php
+// using the methods of database_manager class
function xmldb_qtype_truefalse_upgrade($oldversion=0) {
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
-/// $result = result of "/lib/ddllib.php" function calls
+/// $result = result of database_manager methods
/// }
return $result;