From: stronk7 Date: Wed, 6 Sep 2006 19:47:50 +0000 (+0000) Subject: Now indexes are able to return their PHP specs. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=aed4e5271340863c364acdba02c26839161c26f2;p=moodle.git Now indexes are able to return their PHP specs. --- diff --git a/lib/xmldb/classes/XMLDBIndex.class.php b/lib/xmldb/classes/XMLDBIndex.class.php index 33d5e18f1f..8333b42d5e 100644 --- a/lib/xmldb/classes/XMLDBIndex.class.php +++ b/lib/xmldb/classes/XMLDBIndex.class.php @@ -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 */