sequence properties half implemented
authorxzilla <xzilla>
Thu, 26 Sep 2002 22:04:17 +0000 (22:04 +0000)
committerxzilla <xzilla>
Thu, 26 Sep 2002 22:04:17 +0000 (22:04 +0000)
classes/database/Postgres.php
lang/english.php
public_html/sequences.php

index e83ee2a017375f0f65813d311350740f3bb63454..2249eb0cbec93d29e8848a7ddf8d024de46734c6 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres\r
  * Note: This class uses ADODB and returns RecordSets.\r
  *\r
- * $Id: Postgres.php,v 1.12 2002/09/26 19:25:16 xzilla Exp $\r
+ * $Id: Postgres.php,v 1.13 2002/09/26 22:04:18 xzilla Exp $\r
  */\r
 \r
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???\r
@@ -17,7 +17,7 @@ class Postgres extends BaseDB {
        var $tbFields = array('tbname' => 'tablename', 'tbowner' => 'tableowner');\r
        var $vwFields = array('vwname' => 'viewname', 'vwowner' => 'viewowner', 'vwdef' => 'definition');\r
        var $uFields = array('uname' => 'usename', 'usuper' => 'usesuper', 'ucreatedb' => 'usecreatedb', 'uexpires' => 'valuntil');\r
-       var $sqFields = array('seqname' => 'relname');\r
+       var $sqFields = array('seqname' => 'relname', 'seqowner' => 'usename', 'lastvalue' => 'last_value', 'incrementby' => 'increment_by', 'maxvalue' => 'max_value', 'minvalue'=> 'min_value' );\r
 \r
        // Last oid assigned to a system object\r
        var $_lastSystemOID = 18539;\r
@@ -316,10 +316,23 @@ class Postgres extends BaseDB {
        function &getSequences() {\r
                if (!$this->_showSystem) $where = " AND relname NOT LIKE 'pg_%'";\r
                else $where = '';\r
-               $sql = "SELECT relname FROM pg_class WHERE relkind = 'S'{$where} ORDER BY relname";\r
+               $sql = "SELECT c.relname, u.usename  FROM pg_class c, pg_user u WHERE c.relowner=u.usesysid AND c.relkind = 'S'{$where} ORDER BY relname";\r
                return $this->selectSet( $sql );\r
        }\r
 \r
+\r
+       function &getSequence($sequence) {\r
+               if (!$this->_showSystem) $where = " AND relname NOT LIKE 'pg_%'";\r
+               else $where = '';\r
+               $sql = "SELECT sequence_name as relname,* FROM $sequence"; \r
+               return $this->selectSet( $sql );\r
+       }\r
+\r
+/*\r
+       function setSequence()\r
+       function delSequence()\r
+*/\r
+\r
        /**\r
         * Adds a check constraint to a table\r
         * @param $table The table to which to add the check\r
@@ -607,10 +620,6 @@ class Postgres extends BaseDB {
        function setIndex()\r
        function delIndex()\r
 \r
-       function &getSequences()\r
-       function &getSequence()\r
-       function setSequence()\r
-       function delSequence()\r
 \r
        // DML Functions\r
 \r
index fe5c824a95ccfbe11e4e62eccb41d5b9dfc26517..796a25d0f788fbcca28900a8ca3fcb3e11dc6f09 100755 (executable)
@@ -4,7 +4,7 @@
         * Language template file for WebDB.  Use this to base language
         * files.
         *
-        * $Id: english.php,v 1.6 2002/09/23 06:11:39 chriskl Exp $
+        * $Id: english.php,v 1.7 2002/09/26 22:04:17 xzilla Exp $
         */
 
        $appLang = 'english';
 
        // Sequences
        $strNoSequences = 'No sequences found.';
+       $strSequenceName = 'sequence_name';
+       $strLastValue = 'last_value';
+       $strIncrementBy = 'increment_by';       
+       $strMaxValue = 'max_value';
+       $strMinValue = 'min_value';
+       $strCacheValue = 'cache_value';
+       $strLogCount = 'log_cnt';
+       $strIsCycled = 'is_cycled';
+       $strIsCalled = 'is_called';
        
        // Tables
        $strField = 'Field';
index 7f91ac027ed8f2b98e125ec2f3a036e83f138ef7..9b18e62b9db6f9756d7136ebf3f873dc02cd2a9d 100644 (file)
@@ -3,7 +3,7 @@
  *  FILENAME:   sequence.php
  *  AUTHOR:     Ray Hunter <rhunter@venticon.com>
  *
- *  $Id: sequences.php,v 1.3 2002/09/25 22:10:21 xzilla Exp $
+ *  $Id: sequences.php,v 1.4 2002/09/26 22:04:18 xzilla Exp $
  */
 
 include_once( '../conf/config.inc.php' );
@@ -31,19 +31,25 @@ function doDefault()
     if( $sequences->recordCount() > 0 )
     {
         echo "<table>\n";
-        echo "<tr><th class=\"data\">{$strSequences}</th><th class=\"data\">{$strOwner}</th><th colspan=\"4\" class=\"data\">{$strActions}</th>\n";
+        echo "<tr><th class=\"data\">{$strSequences}</th><th class=\"data\">{$strOwner}</th><th colspan=\"3\" class=\"data\">{$strActions}</th>\n";
         $i = 0;
 
         while( !$sequences->EOF )
         {
             $id = ( ($i % 2 ) == 0 ? '1' : '2' );
-            echo "<tr><td class=\"data{$id}\">", htmlspecialchars( $sequences->f[$data->sqFields['seqname']]), "</td><td>Owner</td><td>Actions</td></tr>\n"; 
+            echo "<tr><td class=\"data{$id}\">", htmlspecialchars( $sequences->f[$data->sqFields['seqname']]), "</td>";
+                       echo "<td class=\"data{$id}\">", htmlspecialchars( $sequences->f[$data->sqFields['seqowner']]), "</td>";
+                       echo "<td class=\"data{$id}\">";
+                               echo "<a href=\"$PHP_SELF?action=properties&database=", htmlspecialchars($_REQUEST['database']), "&sequence=", htmlspecialchars( $sequences->f[$data->sqFields['seqname']]), "\">Properties</a></td>\n"; 
+                       echo "<td class=\"data{$id}\">";
+                               echo "<a href=\"$PHP_SELF?action=drop&database=", htmlspecialchars($_REQUEST['database']), "&sequence=", htmlspecialchars( $sequences->f[$data->sqFields['seqname']]), "\">Drop</td>\n"; 
+                       echo "<td class=\"data{$id}\">";
+                               echo "<a href=\"$PHP_SELF?action=priviledges&database=", htmlspecialchars($_REQUEST['database']), "&sequence=", htmlspecialchars( $sequences->f[$data->sqFields['seqname']]), "\">Privileges</td></tr>\n"; 
 
                        $sequences->movenext();
                        $i++;
         }
 
-
         echo "</table>\n";
     }
     else
@@ -56,6 +62,48 @@ function doDefault()
 }
 // }}}
 
+       function doProperties($msg = '') 
+       {
+               global $data, $localData, $misc, $PHP_SELF;
+               global $strSequences, $strSequenceName, $strLastValue, $strIncrementBy, $strMaxValue, $strMinValue, $strCacheValue, $strLogCount, $strIsCycled, $strIsCalled;
+
+               echo "<h2>", htmlspecialchars($_REQUEST['database']), ": $strSequences : ", htmlspecialchars($_REQUEST['sequence']), ": Properties</h2>\n";
+               $misc->printMsg($msg);
+               
+               $sequence = &$localData->getSequence($_REQUEST['sequence']);
+
+       
+               if ($sequence->recordCount() > 0) {
+
+                       echo"<table border=0>";
+                       echo "<tr><th class=\"data\">$strSequenceName</th><th class=\"data\">$strLastValue</th><th class=\"data\">$strIncrementBy</th><th class=\"data\">$strMaxValue</th><th class=\"data\">$strMinValue</th><th class=\"data\">$strCacheValue</th><th class=\"data\">$strLogCount</th><th class=\"data\">$strIsCycled</th><th class=\"data\">$strIsCalled</th></tr>";
+                       echo "<tr>";
+                       echo "<td class=\"data1\">", $sequence->f[$data->sqFields['seqname']], "</td>";
+                       echo "<td class=\"data1\">", $sequence->f[$data->sqFields['lastvalue']], "</td>";
+                       echo "<td class=\"data1\">", $sequence->f[$data->sqFields['incrementby']], "</td>";
+                       echo "<td class=\"data1\">&nbsp;2147483647&nbsp;</td>";
+                       echo "<td class=\"data1\">&nbsp;1&nbsp;</td>";
+                       echo "<td class=\"data1\">&nbsp;1&nbsp;</td>";
+                       echo "<td class=\"data1\">&nbsp;0&nbsp;</td>";
+                       echo "<td class=\"data1\">&nbsp;No&nbsp;</td>";
+                       echo "<td class=\"data1\">&nbsp;Yes&nbsp;</td>";
+                       echo "</tr>";
+                       echo "</table>";                
+
+               }
+               else echo "<p>No data.</p>\n";
+       }
+
+
+       function doPrivileges()
+       {
+
+       }
+
+       function doDrop()
+       {
+
+       }
 
 echo "<html>\n";
 echo "<body>\n";
@@ -65,6 +113,15 @@ switch( $action )
     case 'create':
         echo "<p>Creating sequence</p>";
         break;
+       case 'properties':
+               doProperties(); 
+               break;
+       case 'drop':
+               doDrop();
+               break;
+       case 'privileges':
+               doPrivileges();
+               break;
     default:
         doDefault();
         break;