Fix drop rule for postgres 7.2 and below
authorchriskl <chriskl>
Mon, 28 Apr 2003 12:00:54 +0000 (12:00 +0000)
committerchriskl <chriskl>
Mon, 28 Apr 2003 12:00:54 +0000 (12:00 +0000)
classes/database/Postgres.php
classes/database/Postgres73.php

index 88b5aedcdb114729492c7b62486d712f7431157b..75dde7d4c253f980fadba5d5e1e7df8b12d2e2ed 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.79 2003/04/23 08:56:26 chriskl Exp $
+ * $Id: Postgres.php,v 1.80 2003/04/28 12:00:54 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -130,8 +130,13 @@ class Postgres extends BaseDB {
        function Postgres($host, $port, $database, $user, $password) {
                $this->BaseDB('postgres7');
 
-               $pghost = "{$host}:{$port}";
-               if ($database === null) $database = 'template1';
+               // Ignore host if null
+               if ($host === null || $host == '')
+                       $pghost = '';
+               else
+                       $pghost = "{$host}:{$port}";
+
+               if ($database === null || $database == '') $database = 'template1';
 
                $this->conn->connect($pghost, $user, $password, $database);
        }
@@ -1252,14 +1257,13 @@ class Postgres extends BaseDB {
        /**
         * Removes a rule from a relation
         * @param $rule The rule to drop
-        * @param $relation The relation from which to drop
+        * @param $relation The relation from which to drop (unused)
         * @return 0 success
         */
        function dropRule($rule, $relation) {
                $this->fieldClean($rule);
-               $this->fieldClean($relation);
 
-               $sql = "DROP RULE \"{$rule}\" ON \"{$relation}\"";
+               $sql = "DROP RULE \"{$rule}\"";
 
                return $this->execute($sql);
        }
index f057e855b6f07973676204fb6f316476a6f72fa9..b23fbed983e849d48e72618568fa5463f1654897 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.34 2003/03/28 12:29:53 chriskl Exp $
+ * $Id: Postgres73.php,v 1.35 2003/04/28 12:00:56 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -610,6 +610,21 @@ class Postgres73 extends Postgres72 {
        }
        
        // Rule functions
+       
+       /**
+        * Removes a rule from a relation
+        * @param $rule The rule to drop
+        * @param $relation The relation from which to drop
+        * @return 0 success
+        */
+       function dropRule($rule, $relation) {
+               $this->fieldClean($rule);
+               $this->fieldClean($relation);
+
+               $sql = "DROP RULE \"{$rule}\" ON \"{$relation}\"";
+
+               return $this->execute($sql);
+       }
 
        /**
         * Returns a list of all rules on a table