From fab1ae559f2a90953197b1e3638237451cead0e9 Mon Sep 17 00:00:00 2001 From: chriskl Date: Wed, 30 Apr 2003 07:35:32 +0000 Subject: [PATCH] Drop CASCADE for triggers --- classes/database/Postgres.php | 8 +++++--- triggers.php | 8 ++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index 9fdc06ff..2feb455e 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -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); } diff --git a/triggers.php b/triggers.php index e9b19aa9..fa0bd582 100644 --- a/triggers.php +++ b/triggers.php @@ -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 @@ -32,11 +32,15 @@ echo "\n"; echo "\n"; echo $misc->form; + // Show cascade drop option if supportd + if ($localData->hasDropBehavior()) { + echo "

{$lang['strcascade']}

\n"; + } echo " \n"; echo "\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 -- 2.39.5