small bet that my pg_get_triggerdef() patch will make it into 7.4 :)
authorchriskl <chriskl>
Sun, 16 Mar 2003 10:56:02 +0000 (10:56 +0000)
committerchriskl <chriskl>
Sun, 16 Mar 2003 10:56:02 +0000 (10:56 +0000)
classes/database/Postgres74.php

index bbbe82f820c14c0a6e41c9f92dbd64fccc450d99..28744051837e96a7e1eb200f4b2a8b33a6990abb 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres74.php,v 1.3 2003/02/09 10:22:39 chriskl Exp $
+ * $Id: Postgres74.php,v 1.4 2003/03/16 10:56:02 chriskl Exp $
  */
 
 include_once('classes/database/Postgres73.php');
@@ -25,6 +25,28 @@ class Postgres74 extends Postgres73 {
                $this->Postgres73($host, $port, $database, $user, $password);
        }
 
+       // Trigger functions
+       
+       /**
+        * Grabs a list of triggers on a table
+        * @param $table The name of a table whose triggers to retrieve
+        * @return A recordset
+        */
+       function &getTriggers($table = '') {
+               $this->clean($table);
+
+               $sql = "SELECT t.tgname, pg_catalog.pg_get_triggerdef(t.oid) AS tgdef
+                       FROM pg_catalog.pg_trigger t
+                       WHERE t.tgrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='{$table}'
+                       AND relnamespace=(SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$this->_schema}'))
+                       AND (NOT tgisconstraint OR NOT EXISTS
+                       (SELECT 1 FROM pg_catalog.pg_depend d    JOIN pg_catalog.pg_constraint c
+                       ON (d.refclassid = c.tableoid AND d.refobjid = c.oid)
+                       WHERE d.classid = t.tableoid AND d.objid = t.oid AND d.deptype = 'i' AND c.contype = 'f'))";
+
+               return $this->selectSet($sql);
+       }
+
        // Constraint functions
 
        /**