]> git.mjollnir.org Git - moodle.git/commitdiff
Now indexes are able to return their PHP specs.
authorstronk7 <stronk7>
Wed, 6 Sep 2006 19:47:50 +0000 (19:47 +0000)
committerstronk7 <stronk7>
Wed, 6 Sep 2006 19:47:50 +0000 (19:47 +0000)
lib/xmldb/classes/XMLDBIndex.class.php

index 33d5e18f1fa00209464adca54f5b55586bab0ced..8333b42d5e9186a420557e5a0470325fea14f1d1 100644 (file)
@@ -211,6 +211,31 @@ class XMLDBIndex extends XMLDBObject {
         $this->changed = true;
     }
 
+    /**
+     * Returns the PHP code needed to define one XMLDBIndex
+     */
+    function getPHP() {
+
+        $result = '';
+
+    /// The type
+        $unique = $this->getUnique();
+        if (!empty($unique)) {
+            $result .= 'XMLDB_INDEX_UNIQUE, ';
+        } else {
+            $result .= 'XMLDB_INDEX_NOTUNIQUE, ';
+        }
+    /// The fields
+        $indexfields = $this->getFields();
+        if (!empty($indexfields)) {
+            $result .= 'array(' . "'".  implode("', '", $indexfields) . "')";
+        } else {
+            $result .= 'null';
+        }
+    /// Return result
+        return $result;
+    }
+
     /**     
      * Shows info in a readable format
      */