From 618a982eed437637ec27e0c7526d63a52320f879 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Tue, 26 Sep 2006 23:15:20 +0000 Subject: [PATCH] Now all the generators support creating and dropping indexes --- .../generators/XMLDBGenerator.class.php | 31 +++++++++++++++++++ .../classes/generators/mssql/mssql.class.php | 3 ++ .../classes/generators/mysql/mysql.class.php | 3 ++ 3 files changed, 37 insertions(+) diff --git a/lib/xmldb/classes/generators/XMLDBGenerator.class.php b/lib/xmldb/classes/generators/XMLDBGenerator.class.php index 03a797747a..0c7030fea5 100644 --- a/lib/xmldb/classes/generators/XMLDBGenerator.class.php +++ b/lib/xmldb/classes/generators/XMLDBGenerator.class.php @@ -104,6 +104,9 @@ class XMLDBgenerator { var $alter_column_skip_notnull = false; //The generator will skip the null/notnull clause on alter columns + var $drop_index_sql = 'DROP INDEX INDEXNAME'; //SQL sentence to drop one index + //TABLENAME, INDEXNAME are dinamically replaced + var $prefix; // Prefix to be used for all the DB objects var $reserved_words; // List of reserved words (in order to quote them properly) @@ -604,6 +607,34 @@ class XMLDBgenerator { } } + /** + * Given one XMLDBTable and one XMLDBIndex, return the SQL statements needded to add the index to the table + */ + function getAddIndexSQL($xmldb_table, $xmldb_index) { + + /// Just use the CreateIndexSQL function + return $this->getCreateIndexSQL($xmldb_table, $xmldb_index); + } + + /** + * Given one XMLDBTable and one XMLDBIndex, return the SQL statements needded to drop the index from the table + */ + function getDropIndexSQL($xmldb_table, $xmldb_index) { + + $results = array(); + + /// Get the real index name + $dbindexname = find_index_name($xmldb_table, $xmldb_index); + + /// Replace TABLENAME and INDEXNAME as needed + $dropsql = str_replace('TABLENAME', $this->getEncQuoted($this->prefix . $xmldb_table->getName()), $this->drop_index_sql); + $dropsql = str_replace('INDEXNAME', $dbindexname, $dropsql); + + $results[] = $dropsql; + + return $results; + } + /** * Given three strings (table name, list of fields (comma separated) and suffix), create the proper object name diff --git a/lib/xmldb/classes/generators/mssql/mssql.class.php b/lib/xmldb/classes/generators/mssql/mssql.class.php index 3b1d4af7c3..61ba212407 100644 --- a/lib/xmldb/classes/generators/mssql/mssql.class.php +++ b/lib/xmldb/classes/generators/mssql/mssql.class.php @@ -60,6 +60,9 @@ class XMLDBmssql extends XMLDBgenerator { var $concat_character = '+'; //Characters to be used as concatenation operator. If not defined //MySQL CONCAT function will be use + var $drop_index_sql = 'DROP INDEX TABLENAME.INDEXNAME'; //SQL sentence to drop one index + //TABLENAME, INDEXNAME are dinamically replaced + /** * Creates one new XMLDBmssql */ diff --git a/lib/xmldb/classes/generators/mysql/mysql.class.php b/lib/xmldb/classes/generators/mysql/mysql.class.php index d0e2dee639..3565067735 100644 --- a/lib/xmldb/classes/generators/mysql/mysql.class.php +++ b/lib/xmldb/classes/generators/mysql/mysql.class.php @@ -60,6 +60,9 @@ class XMLDBmysql extends XMLDBGenerator { var $alter_column_sql = 'ALTER TABLE TABLENAME MODIFY COLUMN COLUMNSPECS'; //The SQL template to alter columns + var $drop_index_sql = 'DROP INDEX INDEXNAME ON TABLENAME'; //SQL sentence to drop one index + //TABLENAME, INDEXNAME are dinamically replaced + /** * Creates one new XMLDBmysql */ -- 2.39.5