|
|
@@ -753,4 +753,23 @@ class Sqlserver extends DboSource {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Generate a "drop table" statement for the given Schema object
|
|
|
+ *
|
|
|
+ * @param CakeSchema $schema An instance of a subclass of CakeSchema
|
|
|
+ * @param string $table Optional. If specified only the table name given will be generated.
|
|
|
+ * Otherwise, all tables defined in the schema are generated.
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function dropSchema(CakeSchema $schema, $table = null) {
|
|
|
+ $out = '';
|
|
|
+ foreach ($schema->tables as $curTable => $columns) {
|
|
|
+ if (!$table || $table == $curTable) {
|
|
|
+ $t = $this->fullTableName($curTable);
|
|
|
+ $out .= "IF OBJECT_ID('" . $this->fullTableName($curTable, false). "', 'U') IS NOT NULL DROP TABLE " . $this->fullTableName($curTable) . ";\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $out;
|
|
|
+ }
|
|
|
+
|
|
|
}
|