Allow editing over non-null values in unique indexes. Auto-detect for 7.4-dev PostgreSQL
authorchriskl <chriskl>
Fri, 28 Mar 2003 12:29:53 +0000 (12:29 +0000)
committerchriskl <chriskl>
Fri, 28 Mar 2003 12:29:53 +0000 (12:29 +0000)
classes/Misc.php
classes/database/Postgres73.php
tables.php

index 57fd2bbd4592e5e903e4000a55215a6a9f645d76..37580b14af8c9be46f79bd3a1b17617a4c5b5ea8 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.19 2003/03/27 13:47:15 chriskl Exp $
+        * $Id: Misc.php,v 1.20 2003/03/28 12:29:53 chriskl Exp $
         */
         
        class Misc {
 
                                        $version = $params[1]; // eg. 7.3.2
 
-                                       if (strpos($version, '7.3') === 0)
+                                       if (strpos($version, '7.4') === 0)
+                                               return 'Postgres74';
+                                       elseif (strpos($version, '7.3') === 0)
                                                return 'Postgres73';
                                        elseif (strpos($version, '7.2') === 0)
                                                return 'Postgres72';
index 8b6c1f71c7f7afdf210354dd3f31d3e077acf707..f057e855b6f07973676204fb6f316476a6f72fa9 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.33 2003/03/27 12:56:30 chriskl Exp $
+ * $Id: Postgres73.php,v 1.34 2003/03/28 12:29:53 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -21,7 +21,7 @@ class Postgres73 extends Postgres72 {
 
        // Last oid assigned to a system object
        var $_lastSystemOID = 16974;
-       
+
        // Max object name length
        var $_maxNameLen = 63;
 
@@ -273,7 +273,7 @@ class Postgres73 extends Postgres72 {
                $status = $this->beginTransaction();
                if ($status != 0) return -1;
                
-               $sql = "SELECT indrelid, indkey FROM pg_index WHERE indisprimary AND 
+               $sql = "SELECT indrelid, indkey FROM pg_index WHERE indisunique AND 
                        indrelid=(SELECT oid FROM pg_class WHERE relname='{$table}' AND
                        relnamespace=(SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$this->_schema}'))";
                $rs = $this->selectSet($sql);
index 89d35dd67a3228b5fbb5c29f6d417f0ce198a088..adeff949d2148667dbb02e0892b959690a75bbe1 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.10 2003/03/23 03:13:57 chriskl Exp $
+        * $Id: tables.php,v 1.11 2003/03/28 12:29:53 chriskl Exp $
         */
 
        // Include application functions
                                        if ($k == $localData->id && !$guiShowOIDs) continue;
                                        elseif ($v == '') echo "<td class=\"data{$id}\">&nbsp;</td>";
                                        else echo "<td class=data{$id}>", nl2br(htmlspecialchars($v)), "</td>";
-                               }                                                       
+                               }
                                if (sizeof($key) > 0) {
                                        $key_str = '';
+                                       $has_nulls = false;
                                        foreach ($key as $v) {
+                                               if ($rs->f[$v] === null) {
+                                                       $has_nulls = true;
+                                                       break;
+                                               }
                                                if ($key_str != '') $key_str .= '&';
                                                $key_str .= urlencode("key[{$v}]") . '=' . urlencode($rs->f[$v]);
                                        }
-
-                                       echo "<td class=opbutton{$id}><a href=\"{$PHP_SELF}?action=confeditrow&{$misc->href}&table=", urlencode($_REQUEST['table']), "&page=", $_REQUEST['page'], "&{$key_str}\">{$lang['stredit']}</a></td>\n";
-                                       echo "<td class=opbutton{$id}><a href=\"{$PHP_SELF}?action=confdelrow&{$misc->href}&table=", urlencode($_REQUEST['table']), "&page=", $_REQUEST['page'], "&{$key_str}\">{$lang['strdelete']}</a></td>\n";
+                                       if ($has_nulls) {
+                                               echo "<td class=opbutton{$id}>&nbsp;</td>\n<td class=opbutton{$id}>&nbsp;</td>\n";
+                                       } else {
+                                               echo "<td class=opbutton{$id}><a href=\"{$PHP_SELF}?action=confeditrow&{$misc->href}&table=", urlencode($_REQUEST['table']), "&page=", $_REQUEST['page'], "&{$key_str}\">{$lang['stredit']}</a></td>\n";
+                                               echo "<td class=opbutton{$id}><a href=\"{$PHP_SELF}?action=confdelrow&{$misc->href}&table=", urlencode($_REQUEST['table']), "&page=", $_REQUEST['page'], "&{$key_str}\">{$lang['strdelete']}</a></td>\n";
+                                       }
                                }
                                echo "</tr>\n";
                                $rs->moveNext();