we can now view the properties of individual functions
authorxzilla <xzilla>
Tue, 10 Sep 2002 18:46:25 +0000 (18:46 +0000)
committerxzilla <xzilla>
Tue, 10 Sep 2002 18:46:25 +0000 (18:46 +0000)
classes/database/Postgres72.php
public_html/functions.php

index 70346546c0440502a0ba31c4d8bed531ce4dcbc3..1ee1fdfe1c9199a2377ca0d878a80283385665d7 100644 (file)
@@ -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: Postgres72.php,v 1.3 2002/09/09 21:16:40 xzilla Exp $\r
+ * $Id: Postgres72.php,v 1.4 2002/09/10 18:46:25 xzilla Exp $\r
  */\r
 \r
 \r
@@ -12,7 +12,7 @@ require_once('../classes/database/Postgres71.php');
 \r
 class Postgres72 extends Postgres71 {\r
 \r
-       var $fnFields = array('fnname' => 'proname', 'fnresult' => 'result', 'fnarguments' => 'arguments','fnoid' => 'oid');\r
+       var $fnFields = array('fnname' => 'proname', 'fnreturns' => 'return_type', 'fnarguments' => 'arguments','fnoid' => 'oid', 'fndef' => 'source', 'fnlang' => 'language' );\r
        \r
        // @@ Set the maximum built-in ID. Should we bother querying for this?\r
        var $_lastSystemOID = 16554;\r
@@ -33,7 +33,7 @@ class Postgres72 extends Postgres71 {
                $sql =  "SELECT \r
                                pc.oid,\r
                                proname, \r
-                               pt.typname AS result\r
+                               pt.typname AS return_type\r
                                oidvectortypes(pc.proargtypes) AS arguments\r
                        FROM \r
                                pg_proc pc, pg_user pu, pg_type pt\r
@@ -54,7 +54,7 @@ class Postgres72 extends Postgres71 {
                                AND pc.prorettype = 0\r
                                AND pc.oid > '$this->_lastSystemOID'::oid\r
                        ORDER BY\r
-                               proname, result\r
+                               proname, return_type\r
                        ";\r
 \r
                return $this->selectSet($sql);\r
@@ -65,11 +65,24 @@ class Postgres72 extends Postgres71 {
         * @param $func The name of the function to retrieve\r
         * @return Function info\r
         */\r
-       function getFunc($func) {\r
-               $this->clean($func);\r
+       function getFunction($function_oid) {\r
+               $this->clean($function_oid);\r
                \r
-               $sql = "SELECT viewname, viewowner, definition FROM pg_views WHERE viewname='$view'";\r
-\r
+               $sql = "SELECT \r
+                                       pc.oid,\r
+                                       proname, \r
+                                       lanname as language,\r
+                                       format_type(prorettype, NULL) as return_type,\r
+                                       prosrc as source,\r
+                                       probin as binary,\r
+                                       oidvectortypes(pc.proargtypes) AS arguments\r
+                               FROM \r
+                                       pg_proc pc, pg_language pl\r
+                               WHERE \r
+                                       pc.oid = '$function_oid'::oid\r
+                               AND pc.prolang = pl.oid\r
+                               ";\r
+       \r
                return $this->selectSet($sql);\r
        }       \r
 \r
index 5f37266cedc45d193718423e3106161b27e98e26..b6e2f7908305b954ed76161b41ec293ed7cde6b3 100644 (file)
@@ -3,7 +3,7 @@
        /**\r
         * Manage functions in a database\r
         *\r
-        * $Id: functions.php,v 1.2 2002/09/09 21:16:40 xzilla Exp $\r
+        * $Id: functions.php,v 1.3 2002/09/10 18:46:25 xzilla Exp $\r
         */\r
 \r
        // Include application functions\r
        }\r
        \r
        /**\r
-        * Show read only properties for a view\r
+        * Show read only properties for a function\r
+                       pc.oid,\r
+                                       proname, \r
+                                       lanname as language,\r
+                                       format_type(prorettype, NULL) as return_type,\r
+                                       prosrc as source,\r
+                                       probin as binary,\r
+                                       oidvectortypes(pc.proargtypes) AS arguments\r
+\r
+\r
+\r
         */\r
        function doProperties($msg = '') {\r
                global $data, $localData, $misc;\r
-               global $PHP_SELF, $strName, $strDefinition;\r
+               global $PHP_SELF, $strFunctions, $strArguments, $strReturns, $strActions, $strNoFunctions, $strDefinition, $strLanguage;\r
        \r
-               echo "<h2>", htmlspecialchars($_REQUEST['database']), ": Views: ", htmlspecialchars($_REQUEST['view']), ": Properties</h2>\n";\r
+               echo "<h2>", htmlspecialchars($_REQUEST['database']), ": Functions: ", htmlspecialchars($_REQUEST['function']), ": Properties</h2>\n";\r
                $misc->printMsg($msg);\r
                \r
-               $viewdata = &$localData->getView($_REQUEST['view']);\r
+               $funcdata = &$localData->getFunction($_REQUEST['function_oid']);\r
                \r
-               if ($viewdata->recordCount() > 0) {\r
-                       echo "<table width=100%>\n";\r
-                       echo "<tr><th class=data>{$strName}</th></tr>\n";\r
-                       echo "<tr><td class=data1>", htmlspecialchars($viewdata->f[$data->vwFields['vwname']]), "</td></tr>\n";\r
-                       echo "<tr><th class=data>{$strDefinition}</th></tr>\n";\r
-                       echo "<tr><td class=data1>", nl2br(htmlspecialchars($viewdata->f[$data->vwFields['vwdef']])), "</td></tr>\n";\r
+               if ($funcdata->recordCount() > 0) {\r
+                       echo "<table width=90%>\n";\r
+                       echo "<tr><th class=data>{$strFunctions}</th>\n";\r
+                       echo "<th class=data>{$strArguments}</th>\n";\r
+                       echo "<th class=data>{$strReturns}</th>\n";\r
+                       echo "<th class=data>{$strLanguage}</th></tr>\n";\r
+                       echo "<tr><td class=data1>", htmlspecialchars($funcdata->f[$data->fnFields['fnname']]), "</td>\n";\r
+                       echo "<td class=data1>", htmlspecialchars($funcdata->f[$data->fnFields['fnarguments']]), "</td>\n";\r
+                       echo "<td class=data1>", htmlspecialchars($funcdata->f[$data->fnFields['fnreturns']]), "</td>\n";\r
+                       echo "<td class=data1>", htmlspecialchars($funcdata->f[$data->fnFields['fnlang']]), "</td></tr>\n";\r
+                       echo "<tr><th class=data colspan=4>{$strDefinition}</th></tr>\n";\r
+                       echo "<tr><td class=data1 colspan=4>", nl2br(htmlspecialchars($funcdata->f[$data->fnFields['fndef']])), "</td></tr>\n";\r
                        echo "</table>\n";\r
                }\r
                else echo "<p>No data.</p>\n";\r
                \r
-               echo "<p><a class=navlink href=\"$PHP_SELF?database=", urlencode($_REQUEST['database']), "\">Show All Views</a> |\n";\r
-               echo "<a class=navlink href=\"$PHP_SELF?action=edit&database=", urlencode($_REQUEST['database']), "&view=", \r
-                       urlencode($_REQUEST['view']), "\">Edit</a></p>\n";\r
+               echo "<p><a class=navlink href=\"$PHP_SELF?database=", urlencode($_REQUEST['database']), "\">Show All Functions</a> |\n";\r
+               echo "<a class=navlink href=\"$PHP_SELF?action=edit&database=", urlencode($_REQUEST['database']), "&function=", \r
+                       urlencode($_REQUEST['function']), "\">Edit</a></p>\n";\r
        }\r
        \r
        /**\r
         */\r
        function doDefault($msg = '') {\r
                global $data, $localData, $misc, $database, $func;\r
-               global $PHP_SELF, $strFunctions, $strParams, $strReturns, $strActions, $strNoFunctions;\r
+               global $PHP_SELF, $strFunctions, $strArguments, $strReturns, $strActions, $strNoFunctions;\r
                \r
                echo "<h2>", htmlspecialchars($_REQUEST['database']), ": Functions</h2>\n";\r
                $misc->printMsg($msg);\r
                \r
                if ($funcs->recordCount() > 0) {\r
                        echo "<table>\n";\r
-                       echo "<tr><th class=data>{$strFunctions}</th><th class=data>{$strReturns}</th><th class=data>{$strParams}</th><th colspan=3 class=data>{$strActions}</th>\n";\r
+                       echo "<tr><th class=data>{$strFunctions}</th><th class=data>{$strReturns}</th><th class=data>{$strArguments}</th><th colspan=3 class=data>{$strActions}</th>\n";\r
                        $i = 0;\r
                        while (!$funcs->EOF) {\r
 \r
 \r
                                $id = (($i % 2) == 0 ? '1' : '2');\r
                                echo "<tr><td class=data{$id}>", htmlspecialchars($funcs->f[$data->fnFields['fnname']]), "</td>\n";\r
-                               echo "<td class=data{$id}>", htmlspecialchars($funcs->f[$data->fnFields['fnresult']]), "</td>\n";\r
+                               echo "<td class=data{$id}>", htmlspecialchars($funcs->f[$data->fnFields['fnreturns']]), "</td>\n";\r
                                echo "<td class=data{$id}>", htmlspecialchars($funcs->f[$data->fnFields['fnarguments']]), "</td>\n";\r
                                echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=properties&database=", \r
-                                       htmlspecialchars($_REQUEST['database']), "&function=", urlencode($funcs->f[$data->fnFields['fnname']]), "\">Properties</a></td>\n";\r
+                                       htmlspecialchars($_REQUEST['database']), "&function=", urlencode($func_full), "&function_oid=", $funcs->f[$data->fnFields['fnoid']], "\">Properties</a></td>\n";\r
                                echo "<td class=opbutton{$id}>Edit</td>\n";\r
                                echo "<td class=opbutton{$id}><a href=\"$PHP_SELF?action=confirm_drop&database=", \r
                                        htmlspecialchars($_REQUEST['database']), "&function=", urlencode($func_full), "&function_oid=", $funcs->f[$data->fnFields['fnoid']], "\">Drop</a></td>\n";\r