From: stronk7 Date: Thu, 7 Sep 2006 18:39:43 +0000 (+0000) Subject: Typos + drop table fully supported. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3a8c55c3fb339a4c6e744feca009402410a63aac;p=moodle.git Typos + drop table fully supported. --- diff --git a/lib/xmldb/classes/XMLDBField.class.php b/lib/xmldb/classes/XMLDBField.class.php index 35a3d20dda..ffa3e1a4d9 100644 --- a/lib/xmldb/classes/XMLDBField.class.php +++ b/lib/xmldb/classes/XMLDBField.class.php @@ -80,7 +80,7 @@ class XMLDBField extends XMLDBObject { $this->precision = $type; $this->unsigned = !empty($unsigned) ? true : false; $this->notnull = !empty($notnull) ? true : false; - $this->sequence = !empty($secuence) ? true : false; + $this->sequence = !empty($sequence) ? true : false; $this->enum = !empty($enum) ? true : false; /// Accept both quoted and non-quoted vales (quoting them)a if (is_array($enumvalues)) { diff --git a/lib/xmldb/classes/generators/XMLDBGenerator.class.php b/lib/xmldb/classes/generators/XMLDBGenerator.class.php index 7404c1e8da..e89e998bd6 100644 --- a/lib/xmldb/classes/generators/XMLDBGenerator.class.php +++ b/lib/xmldb/classes/generators/XMLDBGenerator.class.php @@ -157,7 +157,7 @@ class XMLDBgenerator { } /// Add enum extra code if needed if ($this->enum_extra_code) { - /// Iterate over fields looking for sequences + /// Iterate over fields looking for enums foreach ($xmldb_fields as $xmldb_field) { if ($xmldb_field->getEnum()) { $table .= "\n" . $this->getEnumExtraSQL($xmldb_table, $xmldb_field) . ','; @@ -424,7 +424,7 @@ class XMLDBgenerator { /// TODO, call to getRenameTableExtraSQL() if $rename_table_extra_code is enabled. It will add sequence regeneration code. if ($this->rename_table_extra_code) { - $extra_sentences = getDropTableExtraSQL(); + $extra_sentences = $this->getRenameTableExtraSQL(); $results = array_merge($results, $extra_sentences); } @@ -439,16 +439,17 @@ class XMLDBgenerator { $results = array(); //Array where all the sentences will be stored - $rename = str_replace('TABLENAME', $this->getEncQuoted($this->prefix . $xmldb_table->getName()), $this->drop_table_sql); + $drop = str_replace('TABLENAME', $this->getEncQuoted($this->prefix . $xmldb_table->getName()), $this->drop_table_sql); - $results[] = $rename; + $results[] = $drop; /// TODO, call to getDropTableExtraSQL() if $rename_table_extra_code is enabled. It will add sequence/trigger drop code. if ($this->drop_table_extra_code) { - $extra_sentences = getDropTableExtraSQL(); + $extra_sentences = $this->getDropTableExtraSQL($xmldb_table); $results = array_merge($results, $extra_sentences); } + return $results; } @@ -659,28 +660,28 @@ class XMLDBgenerator { * to create one sequence for the xmldb_table and xmldb_field passes */ function getCreateSequenceSQL ($xmldb_table, $xmldb_field) { - return 'Code for extra sequence SQL goes to getCreateSequenceSQL(). Can be disabled with sequence_extra_code=false'; + return array('Code for extra sequence SQL goes to getCreateSequenceSQL(). Can be disabled with sequence_extra_code=false'); } /** * Returns the code (array of statements) needed to add one comment to the table */ function getCommentSQL ($xmldb_table) { - return 'Code for table comment goes to getCommentSQL(). Can be disabled with add_table_comments=false;'; + return array('Code for table comment goes to getCommentSQL(). Can be disabled with add_table_comments=false;'); } /** * Returns the code (array of statements) needed to execute extra statements on table rename */ function getRenameTableExtraSQL ($xmldb_table) { - return 'Code for table rename goes to getRenameTableExtraSQL(). Can be disabled with rename_table_extra_code=false;'; + return array('Code for table rename goes to getRenameTableExtraSQL(). Can be disabled with rename_table_extra_code=false;'); } /** * Returns the code (array of statements) needed to execute extra statements on table drop */ function getDropTableExtraSQL ($xmldb_table) { - return 'Code for table drop goes to getDropTableExtraSQL(). Can be disabled with drop_table_extra_code=false;'; + return array('Code for table drop goes to getDropTableExtraSQL(). Can be disabled with drop_table_extra_code=false;'); } /** diff --git a/lib/xmldb/classes/generators/oci8po/oci8po.class.php b/lib/xmldb/classes/generators/oci8po/oci8po.class.php index 3055ae5a89..5c2198e29a 100644 --- a/lib/xmldb/classes/generators/oci8po/oci8po.class.php +++ b/lib/xmldb/classes/generators/oci8po/oci8po.class.php @@ -52,6 +52,8 @@ class XMLDBoci8po extends XMLDBgenerator { var $sequence_extra_code = true; //Does the generator need to add extra code to generate the sequence fields var $sequence_name = ''; //Particular name for inline sequences in this generator + var $drop_table_extra_code = true; //Does the generatos need to add code after table drop + var $enum_inline_code = false; //Does the generator need to add inline code in the column definition /** @@ -149,16 +151,46 @@ class XMLDBoci8po extends XMLDBgenerator { return array($sequence, $trigger); } - /** - * Returns the code (in array) needed to add one comment to the table - */ - function getCommentSQL ($xmldb_table) { + /** + * Returns the code needed to drop one sequence for the xmldb_table and xmldb_field passed + * Can, optionally, specify if the underlying trigger will be also dropped + */ + function getDropSequenceSQL ($xmldb_table, $xmldb_field, $include_trigger=false) { + + $sequence_name = $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'seq'); + + $sequence = "DROP SEQUENCE " . $sequence_name; + + $trigger_name = $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'trg'); + + $trigger = "DROP TRIGGER " . $trigger_name; + + if ($include_trigger) { + $result = array($sequence, $trigger); + } else { + $result = array($sequence); + } + return $result; + } + + /** + * Returns the code (in array) needed to add one comment to the table + */ + function getCommentSQL ($xmldb_table) { + + $comment = "COMMENT ON TABLE " . $this->getEncQuoted($this->prefix . $xmldb_table->getName()); + $comment.= " IS '" . substr($xmldb_table->getComment(), 0, 250) . "'"; - $comment = "COMMENT ON TABLE " . $this->getEncQuoted($this->prefix . $xmldb_table->getName()); - $comment.= " IS '" . substr($xmldb_table->getComment(), 0, 250) . "'"; + return array($comment); + } - return array($comment); - } + /** + * Returns the code (array of statements) needed to execute extra statements on table drop + */ + function getDropTableExtraSQL ($xmldb_table) { + $xmldb_field = new XMLDBField('id'); // Fields having sequences should be exclusively, id. + return $this->getDropSequenceSQL($xmldb_table, $xmldb_field, false); + } /** * Returns an array of reserved words (lowercase) for this DB