Drop CASCADE for schemas
authorchriskl <chriskl>
Wed, 30 Apr 2003 07:28:10 +0000 (07:28 +0000)
committerchriskl <chriskl>
Wed, 30 Apr 2003 07:28:10 +0000 (07:28 +0000)
classes/database/Postgres73.php
database.php

index 8bac6d1b524dd75c42028fd2768dd7406bf60557..9fd7bdfdb2ada954f242f931114672a4509c46c7 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres73.php,v 1.37 2003/04/30 07:02:22 chriskl Exp $
+ * $Id: Postgres73.php,v 1.38 2003/04/30 07:28:11 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -137,12 +137,14 @@ class Postgres73 extends Postgres72 {
        /**
         * Drops a schema.
         * @param $schemaname The name of the schema to drop
+        * @param $cascade True to cascade drop, false to restrict
         * @return 0 success
         */
-       function dropSchema($schemaname) {
+       function dropSchema($schemaname, $cascade) {
                $this->fieldClean($schemaname);
                
                $sql = "DROP SCHEMA \"{$schemaname}\"";
+               if ($cascade) $sql .= " CASCADE";
                
                return $this->execute($sql);
        }
@@ -170,38 +172,6 @@ class Postgres73 extends Postgres72 {
                return $this->selectRow($sql);
        }
 
-       /**
-        * Creates a new conversion.
-        * @param $schemaname The name of the schema to create
-        * @param $authorization (optional) The username to create the schema for.
-        * @param $authorization (optional) If omitted, defaults to current user.
-        * @return 0 success
-        */
-        /*
-       function createSchema($schemaname, $authorization = '') {
-               $this->clean($schemaname);
-               $this->clean($authorization);
-               
-               $sql = "CREATE SCHEMA \"{$schemaname}\"";
-               if ($authorization != '') $sql .= " AUTHORIZATION \"{$authorization}\"";
-               
-               return $this->execute($sql);
-       }
-       */
-       /**
-        * Drops a schema.
-        * @param $schemaname The name of the schema to drop
-        * @return 0 success
-        */
-        /*
-       function dropSchema($schemaname) {
-               $this->clean($schemaname);
-               
-               $sql = "DROP SCHEMA \"{$schemaname}\"";
-               
-               return $this->execute($sql);
-       }       
-*/
        // Table functions
 
        /**
index 186881ccf5f8d78fa99b9e8f95f063348035096b..3fb689d24035134901864eea638f43b443788710 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.13 2003/04/19 11:59:09 chriskl Exp $
+        * $Id: database.php,v 1.14 2003/04/30 07:28:10 chriskl Exp $
         */
 
        // Include application functions
                        echo "<input type=\"hidden\" name=\"action\" value=\"drop\">\n";
                        echo "<input type=\"hidden\" name=\"database\" value=\"", htmlspecialchars($_REQUEST['database']), "\">\n";
                        echo "<input type=\"hidden\" name=\"schema\" value=\"", htmlspecialchars($_REQUEST['schema']), "\">\n";
+                       // Show cascade drop option if supportd
+                       if ($localData->hasDropBehavior()) {
+                               echo "<p><input type=\"checkbox\" name=\"cascade\"> {$lang['strcascade']}</p>\n";
+                       }
                        echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\"> <input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\">\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropSchema($_POST['schema']);
+                       $status = $localData->dropSchema($_POST['schema'], isset($_POST['cascade']));
                        if ($status == 0) {
                                $_reload_browser = true;
                                doDefault($lang['strschemadropped']);