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

index 9fdc06ff02e9cf791c58a3dad7aed359b75410f6..2feb455ea2e5c6855aa9f5bffdccfd80f60b96ff 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.85 2003/04/30 07:31:16 chriskl Exp $
+ * $Id: Postgres.php,v 1.86 2003/04/30 07:35:32 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -833,7 +833,7 @@ class Postgres extends BaseDB {
         * @param $cascade True to cascade drop, false to restrict
         * @return 0 success
         */
-       function &dropSequence($sequence, $cascade) {
+       function dropSequence($sequence, $cascade) {
                $this->fieldClean($sequence);
                
                $sql = "DROP SEQUENCE \"{$sequence}\"";
@@ -1838,13 +1838,15 @@ class Postgres extends BaseDB {
         * Drops a trigger
         * @param $tgname The name of the trigger to drop
         * @param $table The table from which to drop the trigger
+        * @param $cascade True to cascade drop, false to restrict
         * @return 0 success
         */
-       function dropTrigger($tgname, $table) {
+       function dropTrigger($tgname, $table, $cascade) {
                $this->fieldClean($tgname);
                $this->fieldClean($table);
 
                $sql = "DROP TRIGGER \"{$tgname}\" ON \"{$table}\"";
+               if ($cascade) $sql .= " CASCADE";
 
                return $this->execute($sql);
        }
index e9b19aa981f61306de819118403dd7f1e5d4fa58..fa0bd5822ced2f8431b38205ead28c1d91533af1 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List triggers on a table
         *
-        * $Id: triggers.php,v 1.11 2003/04/18 11:08:27 chriskl Exp $
+        * $Id: triggers.php,v 1.12 2003/04/30 07:35:32 chriskl Exp $
         */
 
        // Include application functions
                        echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\">\n";
                        echo "<input type=\"hidden\" name=\"trigger\" value=\"", htmlspecialchars($_REQUEST['trigger']), "\">\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=\"yes\" value=\"{$lang['stryes']}\"> <input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\">\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropTrigger($_POST['trigger'], $_POST['table']);
+                       $status = $localData->dropTrigger($_POST['trigger'], $_POST['table'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strtriggerdropped']);
                        else