]> git.mjollnir.org Git - moodle.git/commitdiff
Some changes to ddllib.php to make some functions a bit easier to call.
authormoodler <moodler>
Wed, 4 Oct 2006 09:44:38 +0000 (09:44 +0000)
committermoodler <moodler>
Wed, 4 Oct 2006 09:44:38 +0000 (09:44 +0000)
May not be final ... see MDL-6817 for details.

lib/ddllib.php

index b541993b595707061c2bd5608dd17c184d7c5867..a70d9dc6537f4856540c8be0972d7d41e39768e4 100644 (file)
@@ -251,6 +251,11 @@ function table_exists($table) {
 
     $exists = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
 /// Do this function silenty (to avoid output in install/upgrade process)
     $olddbdebug = $db->debug;
     $db->debug = false;
@@ -290,6 +295,16 @@ function field_exists($table, $field) {
 
     $exists = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) {
+        $table = new XMLDBTable($table);
+    }
+
+/// Retrieve the field object in case just a name was supplied
+    if (is_string($field)) {
+        $field = new XMLDBField($field);
+    }
+
 /// Do this function silenty (to avoid output in install/upgrade process)
     $olddbdebug = $db->debug;
     $db->debug = false;
@@ -337,6 +352,16 @@ function index_exists($table, $index) {
 
     $exists = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) {
+        $table = new XMLDBTable($table);
+    }
+
+/// Retrieve the index object in case just a name was supplied
+    if (is_string($index)) {
+        $index = new XMLDBIndex($index);
+    }
+
 /// Do this function silenty (to avoid output in install/upgrade process)
     $olddbdebug = $db->debug;
     $db->debug = false;
@@ -555,6 +580,11 @@ function drop_table($table, $continue=true, $feedback=true) {
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }
@@ -589,6 +619,11 @@ function rename_table($table, $newname, $continue=true, $feedback=true) {
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }
@@ -628,6 +663,11 @@ function add_field($table, $field, $continue=true, $feedback=true) {
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }
@@ -664,6 +704,11 @@ function drop_field($table, $field, $continue=true, $feedback=true) {
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }
@@ -700,6 +745,12 @@ function change_field_type($table, $field, $continue=true, $feedback=true) {
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+
+    if (is_string($table)) {
+        $table = new XMLDBTable($table);
+    }
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }
@@ -778,6 +829,11 @@ function change_field_enum($table, $field, $continue=true, $feedback=true) {
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }
@@ -808,6 +864,11 @@ function change_field_default($table, $field, $continue=true, $feedback=true) {
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }
@@ -838,6 +899,17 @@ function rename_field($table, $field, $newname, $continue=true, $feedback=true)
 
     global $CFG, $db;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
+/// Retrieve the field object in case just a name was supplied
+    if (is_string($field)) {
+        $field = new XMLDBField($field);
+    }
+
+
     $status = true;
 
     if (strtolower(get_class($table)) != 'xmldbtable') {
@@ -888,6 +960,11 @@ function add_key($table, $key, $continue=true, $feedback=true) {
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }
@@ -922,6 +999,11 @@ function drop_key($table, $key, $continue=true, $feedback=true) {
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }
@@ -960,6 +1042,11 @@ function rename_key($table, $key, $newname, $continue=true, $feedback=true) {
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }
@@ -998,6 +1085,11 @@ function add_index($table, $index, $continue=true, $feedback=true) {
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }
@@ -1035,6 +1127,17 @@ function drop_index($table, $index, $continue=true, $feedback=true) {
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+
+/// Retrieve the index object in case just a name was supplied
+    if (is_string($index)) {
+        $index = new XMLDBIndex($index);
+    }
+
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }
@@ -1076,6 +1179,16 @@ function rename_index($table, $index, $newname, $continue=true, $feedback=true)
 
     $status = true;
 
+/// Retrieve the table object in case just a name was supplied
+    if (is_string($table)) { 
+        $table = new XMLDBTable($table);
+    }
+/// Retrieve the index object in case just a name was supplied
+    if (is_string($index)) {
+        $index = new XMLDBIndex($index);
+    }
+
+
     if (strtolower(get_class($table)) != 'xmldbtable') {
         return false;
     }