Drop CASCADE for types
authorchriskl <chriskl>
Wed, 30 Apr 2003 07:37:39 +0000 (07:37 +0000)
committerchriskl <chriskl>
Wed, 30 Apr 2003 07:37:39 +0000 (07:37 +0000)
classes/database/Postgres.php
types.php

index 2feb455ea2e5c6855aa9f5bffdccfd80f60b96ff..3efc4d8bc7b430e2f0a42662b72b6b66db7f194b 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.86 2003/04/30 07:35:32 chriskl Exp $
+ * $Id: Postgres.php,v 1.87 2003/04/30 07:37:39 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -1680,12 +1680,14 @@ class Postgres extends BaseDB {
        /**
         * Drops a type.
         * @param $typname The name of the type to drop
+        * @param $cascade True to cascade drop, false to restrict
         * @return 0 success
         */
-       function dropType($typname) {
+       function dropType($typname, $cascade) {
                $this->fieldClean($typname);
 
                $sql = "DROP TYPE \"{$typname}\"";
+               if ($cascade) $sql .= " CASCADE";
 
                return $this->execute($sql);
        }
index 1b0383d555925be3e862f2b82286a8898e27c58a..1560557b3463d4baba747946a4c4627ab18af4ac 100644 (file)
--- a/types.php
+++ b/types.php
@@ -3,7 +3,7 @@
        /**
         * Manage types in a database
         *
-        * $Id: types.php,v 1.5 2003/03/17 05:20:30 chriskl Exp $
+        * $Id: types.php,v 1.6 2003/04/30 07:37:39 chriskl Exp $
         */
 
        // Include application functions
                        echo "<input type=\"hidden\" name=\"action\" value=\"drop\">\n";
                        echo "<input type=\"hidden\" name=\"type\" value=\"", htmlspecialchars($_REQUEST['type']), "\">\n";
                        echo $misc->form;
+                       // 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=\"choice\" value=\"{$lang['stryes']}\"> <input type=submit name=choice value=\"{$lang['strno']}\">\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropType($_POST['type']);
+                       $status = $localData->dropType($_POST['type'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strtypedropped']);
                        else