single db connection mega-commit. phpPgAdmin now only makes one connection to the...
authorchriskl <chriskl>
Wed, 10 Dec 2003 16:03:29 +0000 (16:03 +0000)
committerchriskl <chriskl>
Wed, 10 Dec 2003 16:03:29 +0000 (16:03 +0000)
41 files changed:
BUGS
DEVELOPERS
HISTORY
all_db.php
bottombar.php
browser.php
casts.php
classes/Misc.php
classes/Reports.php
classes/database/ADODB_base.php
classes/database/BaseDB.php
classes/database/Connection.php [new file with mode: 0755]
classes/database/Postgres.php
classes/database/Postgres71.php
classes/database/Postgres72.php
classes/database/Postgres73.php
classes/database/Postgres74.php
classes/database/Postgres75.php
constraints.php
conversions.php
database.php
dataexport.php
display.php
domains.php
functions.php
indexes.php
info.php
languages.php
libraries/lib.inc.php
operators.php
privileges.php
rules.php
schema.php
sequences.php
sql.php
sqledit.php
tables.php
tblproperties.php
triggers.php
types.php
views.php

diff --git a/BUGS b/BUGS
index 38b7f9b34ceb683d48dcc926cf9e287bf384022f..2791957624cccfe8c4a6059b08dd142d5f4cad9e 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -15,7 +15,10 @@ fix constraint search to get domain and table constraints?
 dump sequences when dumping tables
 fix dumping clustering info
 can't edit SELECT results by oid
-use LINK REL to speed up page loading times for CSS
 investigate phpPgInfo
 
+Fix
+---
+
+* Does dropping a database work at all?
 
index bf76c99cd435d8314628f12c6ac6028f6514b290..48c3833a759d66f6ae661058ad1423cb7f9b3c56 100644 (file)
@@ -72,8 +72,7 @@ HREFs and htmlspecialchars() variables in forms.
 COMMON VARIABLES
 ----------------
 
-$data - A data connection to the template1 database.
-$localData - A data connection to the current database.
+$data - A data connection to the current or default database.
 $misc - Contains miscellaneous functions.  eg. printing headers and footers, etc.
 $lang - Global array containing translated strings.  The strings in this array have already
         been converted to HTML, so you should not htmlspecialchars() them.
diff --git a/HISTORY b/HISTORY
index 01c41ef74426c8fd8dab004a94a565c647e615a1..fec5f14bb0238e1363628b6276f3bfcdbc919bcc 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -4,6 +4,10 @@ phpPgAdmin History
 Version 3.3-dev
 ---------------
 
+Features
+* Large speed improvements by reducing number of database
+  connections and using external style sheet.
+
 Bugs
 * Object browser fixed for databases with no schemas
 
index c1cd969440b2390f708bc5315d9560ca2bfd4e28..8ee0e904015ec9fe9808846441b25076b7f17cc0 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage databases within a server
         *
-        * $Id: all_db.php,v 1.18 2003/09/30 09:33:43 soranzo Exp $
+        * $Id: all_db.php,v 1.19 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -17,7 +17,7 @@
         * Show confirmation of drop and perform actual drop
         */
        function doDrop($confirm) {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang, $_reload_drop_database;
 
                if ($confirm) { 
@@ -32,7 +32,6 @@
                        echo "</form>\n";
                }
                else {
-                       $localData->close();
                        $status = $data->dropDatabase($_POST['database']);
                        if ($status == 0) {
                                $_reload_drop_database = true;
index 6aa3462070937ad51758d372ce766613396bc605..cbb1258efd1f08b05fbc94677ae1dd63bf5750ae 100644 (file)
@@ -1,12 +1,13 @@
 <?php
 
        /**
-        * Top menu for phpPgAdmin
+        * Bottom bar
         *
-        * $Id: bottombar.php,v 1.1 2003/05/26 11:33:22 chriskl Exp $
+        * $Id: bottombar.php,v 1.2 2003/12/10 16:03:29 chriskl Exp $
         */     
 
-        // Include application functions
+       // Include application functions (no db conn)
+       $_no_db_connection = true;
         include_once('libraries/lib.inc.php');
 
        $misc->printHeader();
index daaad3db17e5c588e672729cb5c78f827cb2a174..ee3ab85ed7103f6c90629b8300fcb2e74000921f 100644 (file)
@@ -5,7 +5,7 @@
         * if you click on a database it shows a list of database objects in that
         * database.
         *
-        * $Id: browser.php,v 1.28 2003/12/05 07:29:58 chriskl Exp $
+        * $Id: browser.php,v 1.29 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -36,7 +36,7 @@
         * @param $schemanode Node onto which to add
         */     
        function addNodes(&$schemanode, $querystr) {
-               global $data, $localData, $misc, $lang, $conf;
+               global $data, $misc, $lang, $conf;
                
                // Session tracking
                $querystr .= '&' . SID;
@@ -54,7 +54,7 @@
                        // Add table folder to schema
                        $schemanode->addItem($table_node);
                        
-                       $tables = &$localData->getTables();
+                       $tables = &$data->getTables();
                        while (!$tables->EOF) {
                                $return_url = urlencode("tblproperties.php?table=" . urlencode($tables->f[$data->tbFields['tbname']]) . "&{$querystr}");
                                $item_node = &new HTML_TreeNode(array(
                
                        // If database supports schemas, add the extra level of hierarchy
                        if ($data->hasSchemas()) {
-                               $schemas = &$localData->getSchemas();
+                               $schemas = &$data->getSchemas();
                                while (!$schemas->EOF) {
-                                       $localData->setSchema($schemas->f[$data->nspFields['nspname']]);
+                                       $data->setSchema($schemas->f[$data->nspFields['nspname']]);
                                        // Construct database & schema query string
                                        $querystr = 'database=' . urlencode($databases->f[$data->dbFields['dbname']]). '&schema=' .
                                                        urlencode($schemas->f[$data->nspFields['nspname']]);
index a502a65870294426ea6b582ac1cd5756da314e52..407a4c86d16ac01c0e8b79b51565399c03f362be 100644 (file)
--- a/casts.php
+++ b/casts.php
@@ -3,7 +3,7 @@
        /**
         * Manage casts in a database
         *
-        * $Id: casts.php,v 1.3 2003/10/28 04:02:14 chriskl Exp $
+        * $Id: casts.php,v 1.4 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
         * Show default list of casts in the database
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc, $database;
+               global $data, $misc, $database;
                global $PHP_SELF, $lang;
 
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strcasts']}</h2>\n";
                $misc->printMsg($msg);
                
-               $casts = &$localData->getcasts();
+               $casts = &$data->getcasts();
 
                if ($casts->recordCount() > 0) {
                        echo "<table>\n";
index c4d666cdb0969df90ec52d55dc118c37f4146b12..683c5bbda6ba467b44f6f87271bae16e5bf0e023 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.49 2003/12/10 14:23:39 chriskl Exp $
+        * $Id: Misc.php,v 1.50 2003/12/10 16:03:30 chriskl Exp $
         */
         
        class Misc {
                /**
                 * Creates a database accessor
                 */
-               function &getDatabaseAccessor($host, $port, $database, $username, $password) {
+               function &getDatabaseAccessor($database) {
                        global $conf;
-                       
-                       $desc = null;
-                       $type = $this->getDriver($host, $port, $username, $password, 
-                                                        $conf['servers'][$_SESSION['webdbServerID']]['type'], 
-                                                        $conf['servers'][$_SESSION['webdbServerID']]['defaultdb'], $desc);
-                       include_once('classes/database/' . $type . '.php');
-                       $localData = new $type( $host,
-                                                                                       $port,
-                                                                                       $database,
-                                                                                       $username,
-                                                                                       $password);
-                       
-                       return $localData;
-               }
 
-               /**
-                * Gets the name of the correct database driver to use
-                * @param $host The hostname to connect to
-                * @param $port The port to connect to
-                * @param $user The username to use
-                * @param $password The password to use
-                * @param $type The ADODB database type name.
-                * @param $database The default database to which to connect
-                * @param (return-by-ref) $description A description of the database and version
-                * @return The class name of the driver eg. Postgres73
-                * @return -1 Database functions not compiled in
-                * @return -2 Invalid database type
-                * @return -3 Database-specific failure
-                */
-               function getDriver($host, $port, $user, $password, $type, $database, &$description) {
-                       switch ($type) {
-                               case 'postgres7':
-                                       // Check functions are loaded
-                                       if (!function_exists('pg_connect')) return -1;
-
-                                       include_once('classes/database/ADODB_base.php');
-                                       $adodb = new ADODB_base('postgres7');
-
-                                       $adodb->conn->connect(($host === null || $host == '') ? null : "{$host}:{$port}", $user, $password, $database);
-
-                                       $sql = "SELECT VERSION() AS version";
-                                       $field = $adodb->selectField($sql, 'version');
-
-                                       $params = explode(' ', $field);
-                                       if (!isset($params[1])) return -3;
-
-                                       $version = $params[1]; // eg. 7.3.2
-                                       $description = "PostgreSQL {$params[1]}";
-
-                                       // Detect version and choose appropriate database driver
-                                       // If unknown version, then default to latest driver
-                                       // All 6.x versions default to oldest driver, even though
-                                       // it won't work with those versions.
-                                       if (strpos($version, '7.4') === 0)
-                                               return 'Postgres74';
-                                       elseif (strpos($version, '7.3') === 0)
-                                               return 'Postgres73';
-                                       elseif (strpos($version, '7.2') === 0)
-                                               return 'Postgres72';
-                                       elseif (strpos($version, '7.1') === 0)
-                                               return 'Postgres71';
-                                       elseif (strpos($version, '7.0') === 0
-                                                       || strpos($version, '6.') === 0)
-                                               return 'Postgres';
-                                       else
-                                               return 'Postgres75';
-
-                                       break;
-                               default:
-                                       return -2;
-                       }
+                       // Create the connection object and make the connection
+                       $_connection = new Connection(
+                               $conf['servers'][$_SESSION['webdbServerID']]['host'],
+                               $conf['servers'][$_SESSION['webdbServerID']]['port'],
+                               $_SESSION['webdbUsername'],
+                               $_SESSION['webdbPassword'],
+                               $database
+                       );
+
+                       // Get the name of the database driver we need to use.  The description
+                       // of the server is returned and placed into the conf array.
+                       $_type = $_connection->getDriver($desc);
+                       // XXX: NEED TO CHECK RETURN STATUS HERE
+
+                       // Create a database wrapper class for easy manipulation of the
+                       // connection.
+                       include_once('classes/database/' . $_type . '.php');
+                       $data = &new $_type($_connection->conn);
+
+                       return $data;
                }
 
+
                /**
                 * Prints the page header.  If global variable $_no_output is
                 * set then no header is drawn.
                                
                                // Theme
                                echo "<link rel=\"stylesheet\" href=\"themes/{$conf['theme']}/global.css\" type=\"text/css\" />\n";
-                               if ($script) echo "\n {$script} \n";
+                               if ($script) echo "{$script}\n";
                                echo "</head>\n";
                        }
                }
index 43f90e95d3f871c56ad9a44f30dcd59d8b5ad846..e462a709f98cfa1ddcb26dbdd38cf2666144bfc6 100644 (file)
@@ -4,7 +4,7 @@
         * the functions provided by the database driver exclusively, and hence
         * will work with any database without modification.
         *
-        * $Id: Reports.php,v 1.8 2003/11/05 08:32:03 chriskl Exp $
+        * $Id: Reports.php,v 1.9 2003/12/10 16:03:30 chriskl Exp $
         */
 
        class Reports {
 
                /* Constructor */
                function Reports() {
-                       global $conf, $misc;
+                       global $misc;
 
                        // Create a new database access object.
                        // @@ IF THE phppgadmin DATABASE DOES NOT EXIST THEN
                        // @@ LOGIN FAILURE OCCURS
-                       $this->driver = &$misc->getDatabaseAccessor(
-                               $conf['servers'][$_SESSION['webdbServerID']]['host'],
-                               $conf['servers'][$_SESSION['webdbServerID']]['port'],
-                               'phppgadmin',
-                               $_SESSION['webdbUsername'],
-                               $_SESSION['webdbPassword']);
+                       $this->driver = &$misc->getDatabaseAccessor('phppgadmin');
                }
 
                /**
index 6993ed8823e2ef306fcfedf34e18d4a7a1a47e91..165f721af8f4525e33375ed7f5dd3c0d1c9ee16e 100644 (file)
@@ -3,7 +3,7 @@
 /*
  * Parent class of all ADODB objects.
  *
- * $Id: ADODB_base.php,v 1.14 2003/07/31 01:17:05 chriskl Exp $
+ * $Id: ADODB_base.php,v 1.15 2003/12/10 16:03:30 chriskl Exp $
  */
 
 include_once('libraries/errorhandler.inc.php');
@@ -15,11 +15,10 @@ class ADODB_base {
 
        /**
         * Base constructor
-        * @param $fetchMode Defaults to associative.  Override for different behaviour
+        * @param &$conn The connection object
         */
-       function ADODB_base($type, $fetchMode = ADODB_FETCH_ASSOC) {
-               $this->conn = &ADONewConnection($type);
-               $this->conn->setFetchMode($fetchMode);
+       function ADODB_base(&$conn) {
+               $this->conn = $conn;
        }
 
        /**
index 86b73a7f63dd1e6f20887e65ef89d78ca976e772..1bbce9c51ea2461d95888bf3fbaf09c5c8cd98a0 100644 (file)
@@ -4,15 +4,15 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: BaseDB.php,v 1.34 2003/11/05 15:06:23 chriskl Exp $
+ * $Id: BaseDB.php,v 1.35 2003/12/10 16:03:30 chriskl Exp $
  */
 
 include_once('classes/database/ADODB_base.php');
 
 class BaseDB extends ADODB_base {
 
-       function BaseDB($type) {
-               $this->ADODB_base($type);
+       function BaseDB($conn) {
+               $this->ADODB_base($conn);
        }
 
        // Table functions
diff --git a/classes/database/Connection.php b/classes/database/Connection.php
new file mode 100755 (executable)
index 0000000..7662c43
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+
+/**
+ * Class to represent a database connection
+ *
+ * $Id: Connection.php,v 1.1 2003/12/10 16:03:30 chriskl Exp $
+ */
+
+include_once('classes/database/ADODB_base.php');
+
+class Connection {
+
+       var $conn;
+
+       /**
+        * Creates a new connection.  Will actually make a database connection.
+        * @param $fetchMode Defaults to associative.  Override for different behaviour
+        */
+       function Connection($host, $port, $user, $password, $database, $fetchMode = ADODB_FETCH_ASSOC) {
+               $this->conn = &ADONewConnection('postgres7');
+               $this->conn->setFetchMode($fetchMode);
+
+               // Ignore host if null
+               if ($host === null || $host == '')
+                       $pghost = '';
+               else
+                       $pghost = "{$host}:{$port}";
+
+               $this->conn->connect($pghost, $user, $password, $database);
+       }
+
+       /**
+        * Gets the name of the correct database driver to use
+        * @param (return-by-ref) $description A description of the database and version
+        * @return The class name of the driver eg. Postgres73
+        * @return -3 Database-specific failure
+        */
+       function getDriver(&$description) {
+               $adodb = new ADODB_base($this->conn);
+
+               $sql = "SELECT VERSION() AS version";
+               $field = $adodb->selectField($sql, 'version');
+
+               $params = explode(' ', $field);
+               if (!isset($params[1])) return -3;
+
+               $version = $params[1]; // eg. 7.3.2
+               $description = "PostgreSQL {$params[1]}";
+
+               // Detect version and choose appropriate database driver
+               // If unknown version, then default to latest driver
+               // All 6.x versions default to oldest driver, even though
+               // it won't work with those versions.
+               if (strpos($version, '7.4') === 0)
+                       return 'Postgres74';
+               elseif (strpos($version, '7.3') === 0)
+                       return 'Postgres73';
+               elseif (strpos($version, '7.2') === 0)
+                       return 'Postgres72';
+               elseif (strpos($version, '7.1') === 0)
+                       return 'Postgres71';
+               elseif (strpos($version, '7.0') === 0
+                               || strpos($version, '6.') === 0)
+                       return 'Postgres';
+               else
+                       return 'Postgres75';
+       }
+
+}
index 74ebe2d42426ccbc9778934b7f0a6013ba1850a4..a947cc3cd6954d01c70853aee1e62a7393446601 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.164 2003/11/19 02:12:47 chriskl Exp $
+ * $Id: Postgres.php,v 1.165 2003/12/10 16:03:30 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -126,22 +126,10 @@ class Postgres extends BaseDB {
 
        /**
         * Constructor
-        * @param $host The hostname to connect to
-        * @param $post The port number to connect to
-        * @param $database The database name to connect to.
-        * @param $user The user to connect as
-        * @param $password The password to use
-        */
-       function Postgres($host, $port, $database, $user, $password) {
-               $this->BaseDB('postgres7');
-
-               // Ignore host if null
-               if ($host === null || $host == '')
-                       $pghost = '';
-               else
-                       $pghost = "{$host}:{$port}";
-
-               $this->conn->connect($pghost, $user, $password, $database);
+        * @param $conn The database connection
+        */
+       function Postgres($conn) {
+               $this->BaseDB($conn);
        }
 
        /**
index f61ec5414a415a366d61f91180a626244a714f06..f176e2933c97c59c4ce087d08d0f1b7d26f22a04 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres71.php,v 1.46 2003/11/05 15:06:24 chriskl Exp $
+ * $Id: Postgres71.php,v 1.47 2003/12/10 16:03:30 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -51,14 +51,10 @@ class Postgres71 extends Postgres {
 
        /**
         * Constructor
-        * @param $host The hostname to connect to
-        * @param $post The port number to connect to
-        * @param $database The database name to connect to
-        * @param $user The user to connect as
-        * @param $password The password to use
+        * @param $conn The database connection
         */
-       function Postgres71($host, $port, $database, $user, $password) {
-               $this->Postgres($host, $port, $database, $user, $password);
+       function Postgres71($conn) {
+               $this->Postgres($conn);
        }
 
        /**
index b4a64daa8903a1de449896b870f558a49568c0af..51c73b96b68e191b0a2b2f041e8208183f25d44a 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres72.php,v 1.52 2003/10/13 08:50:04 chriskl Exp $
+ * $Id: Postgres72.php,v 1.53 2003/12/10 16:03:30 chriskl Exp $
  */
 
 
@@ -28,14 +28,10 @@ class Postgres72 extends Postgres71 {
 
        /**
         * Constructor
-        * @param $host The hostname to connect to
-        * @param $post The port number to connect to
-        * @param $database The database name to connect to
-        * @param $user The user to connect as
-        * @param $password The password to use
+        * @param $conn The database connection
         */
-       function Postgres72($host, $port, $database, $user, $password) {
-               $this->Postgres71($host, $port, $database, $user, $password);
+       function Postgres72($conn) {
+               $this->Postgres71($conn);
 
                // Correct the error in the encoding tables, that was
                // fixed in PostgreSQL 7.2
index 86d7c5f1c8444953c12022553239c82dd960d294..27a851485f1cd49221f3c22c49671ee5770d46b2 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.81 2003/11/24 13:59:37 chriskl Exp $
+ * $Id: Postgres73.php,v 1.82 2003/12/10 16:03:30 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -46,17 +46,13 @@ class Postgres73 extends Postgres72 {
        var $selectOps = array('=' => 'i', '!=' => 'i', '<' => 'i', '>' => 'i', '<=' => 'i', '>=' => 'i', 'LIKE' => 'i', 'NOT LIKE' => 'i', 'ILIKE' => 'i', 'NOT ILIKE' => 'i', 
                                                                        'SIMILAR TO' => 'i', 'NOT SIMILAR TO' => 'i', '~' => 'i', '!~' => 'i', '~*' => 'i', '!~*' => 'i', 'IS NULL' => 'p', 'IS NOT NULL' => 'p',
                                                                        'IN' => 'x', 'NOT IN' => 'x');
-       
+
        /**
         * Constructor
-        * @param $host The hostname to connect to
-        * @param $post The port number to connect to
-        * @param $database The database name to connect to
-        * @param $user The user to connect as
-        * @param $password The password to use
+        * @param $conn The database connection
         */
-       function Postgres73($host, $port, $database, $user, $password) {
-               $this->Postgres72($host, $port, $database, $user, $password);
+       function Postgres73($conn) {
+               $this->Postgres72($conn);
        }
 
        // Schema functions
index b87b6d37cb3225d9263f0b54fa241f5db9eb865d..81f1263c0b2208f83137ccf6ebbbf58cfa6d7d65 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.19 2003/11/19 02:12:48 chriskl Exp $
+ * $Id: Postgres74.php,v 1.20 2003/12/10 16:03:30 chriskl Exp $
  */
 
 include_once('classes/database/Postgres73.php');
@@ -19,14 +19,10 @@ class Postgres74 extends Postgres73 {
 
        /**
         * Constructor
-        * @param $host The hostname to connect to
-        * @param $post The port number to connect to
-        * @param $database The database name to connect to
-        * @param $user The user to connect as
-        * @param $password The password to use
+        * @param $conn The database connection
         */
-       function Postgres74($host, $port, $database, $user, $password) {
-               $this->Postgres73($host, $port, $database, $user, $password);
+       function Postgres74($conn) {
+               $this->Postgres73($conn);
        }
 
        // Table functions
index d423a4300a577e8fb6049f33d79ed48d6f714207..00e22ae7bed75783bf9c313f0520cc6b37ad73e3 100755 (executable)
@@ -3,7 +3,7 @@
 /**
  * PostgreSQL 7.5 support
  *
- * $Id: Postgres75.php,v 1.1 2003/11/09 08:29:33 chriskl Exp $
+ * $Id: Postgres75.php,v 1.2 2003/12/10 16:03:30 chriskl Exp $
  */
 
 include_once('classes/database/Postgres74.php');
@@ -15,14 +15,10 @@ class Postgres75 extends Postgres74 {
 
        /**
         * Constructor
-        * @param $host The hostname to connect to
-        * @param $post The port number to connect to
-        * @param $database The database name to connect to
-        * @param $user The user to connect as
-        * @param $password The password to use
+        * @param $conn The database connection
         */
-       function Postgres75($host, $port, $database, $user, $password) {
-               $this->Postgres74($host, $port, $database, $user, $password);
+       function Postgres75($conn) {
+               $this->Postgres74($conn);
        }
 
 }
index 69f1026d2684909426bdf49da08b2d59269f09e7..a46384ee5fbdab1a92f1fd4782f57af4001fd40f 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List constraints on a table
         *
-        * $Id: constraints.php,v 1.22 2003/10/08 02:14:24 chriskl Exp $
+        * $Id: constraints.php,v 1.23 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -17,7 +17,7 @@
         * Show confirmation of cluster index and perform actual cluster
         */
        function doClusterIndex($confirm) {
-               global $localData, $database, $misc, $action;
+               global $database, $misc, $action;
                global $PHP_SELF, $lang;
 
                if ($confirm) {
@@ -40,7 +40,7 @@
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->clusterIndex($_POST['constraint'], $_POST['table'], isset($_POST['analyze']));
+                       $status = $data->clusterIndex($_POST['constraint'], $_POST['table'], isset($_POST['analyze']));
                        if ($status == 0)
                                doDefault($lang['strclusteredgood'] . ((isset($_POST['analyze']) ? ' ' . $lang['stranalyzegood'] : '')));
                        else
@@ -52,7 +52,7 @@
         * Confirm and then actually add a FOREIGN KEY constraint
         */
        function addForeignKey($stage, $msg = '') {
-               global $PHP_SELF, $data, $localData, $misc;
+               global $PHP_SELF, $data, $data, $misc;
                global $lang;
 
                if (!isset($_POST['name'])) $_POST['name'] = '';
 
                                // Unserialize target and fetch appropriate table.  This is a bit messy
                                // because the table could be in another schema.
-                               if ($localData->hasSchemas()) {
-                                       $localData->setSchema($_REQUEST['target']['schemaname']);
+                               if ($data->hasSchemas()) {
+                                       $data->setSchema($_REQUEST['target']['schemaname']);
                                }
-                               $attrs = &$localData->getTableAttributes($_REQUEST['target']['tablename']);
-                               if ($localData->hasSchemas()) {
-                                       $localData->setSchema($_REQUEST['schema']);
+                               $attrs = &$data->getTableAttributes($_REQUEST['target']['tablename']);
+                               if ($data->hasSchemas()) {
+                                       $data->setSchema($_REQUEST['schema']);
                                }
 
                                $selColumns = new XHTML_select('TableColumnList', true, 10);
                                                || sizeof($_POST['IndexColumnList']) == 0 || !isset($temp) 
                                                || !is_array($temp) || sizeof($temp) == 0) addForeignKey(2, $lang['strfkneedscols']);
                                else {
-                                       $status = $localData->addForeignKey($_POST['table'], $_POST['target']['schemaname'], $_POST['target']['tablename'], 
+                                       $status = $data->addForeignKey($_POST['table'], $_POST['target']['schemaname'], $_POST['target']['tablename'], 
                                                unserialize($_POST['SourceColumnList']), $_POST['IndexColumnList'], $_POST['upd_action'], $_POST['del_action'], $_POST['name']);
                                        if ($status == 0)
                                                doDefault($lang['strfkadded']);
                                        $misc->printVal($_REQUEST['table']), ": {$lang['straddfk']}</h2>\n";
                                $misc->printMsg($msg);
 
-                               $attrs = &$localData->getTableAttributes($_REQUEST['table']);
-                               $tables = &$localData->getTables(true);
+                               $attrs = &$data->getTableAttributes($_REQUEST['table']);
+                               $tables = &$data->getTables(true);
 
                                $selColumns = new XHTML_select('TableColumnList', true, 10);
                                $selColumns->set_style('width: 10em;');
                                        $key = array('schemaname' => $tables->f['schemaname'], 'tablename' => $tables->f['tablename']);
                                        $key = serialize($key);
                                        echo "<option value=\"", htmlspecialchars($key), "\">";
-                                       if ($localData->hasSchemas() && $tables->f['schemaname'] != $_REQUEST['schema']) {
+                                       if ($data->hasSchemas() && $tables->f['schemaname'] != $_REQUEST['schema']) {
                                                        echo htmlspecialchars($tables->f['schemaname']), '.';
                                        }
                                        echo htmlspecialchars($tables->f['tablename']), "</option>\n";
         * Confirm and then actually add a PRIMARY KEY or UNIQUE constraint
         */
        function addPrimaryOrUniqueKey($type, $confirm, $msg = '') {
-               global $PHP_SELF, $data, $localData, $misc;
+               global $PHP_SELF, $data, $data, $misc;
                global $lang;
 
                if (!isset($_POST['name'])) $_POST['name'] = '';
                                $misc->printVal($_REQUEST['table']), ": {$desc}</h2>\n";
                        $misc->printMsg($msg);
                        
-                       $attrs = &$localData->getTableAttributes($_REQUEST['table']);
+                       $attrs = &$data->getTableAttributes($_REQUEST['table']);
        
                        $selColumns = new XHTML_select('TableColumnList', true, 10);
                        $selColumns->set_style('width: 10em;');
                                if (!isset($_POST['IndexColumnList']) || !is_array($_POST['IndexColumnList'])
                                                || sizeof($_POST['IndexColumnList']) == 0) addPrimaryOrUniqueKey($_POST['type'], true, $lang['strpkneedscols']);
                                else {
-                                       $status = $localData->addPrimaryKey($_POST['table'], $_POST['IndexColumnList'], $_POST['name']);
+                                       $status = $data->addPrimaryKey($_POST['table'], $_POST['IndexColumnList'], $_POST['name']);
                                        if ($status == 0)
                                                doDefault($lang['strpkadded']);
                                        else
                                if (!isset($_POST['IndexColumnList']) || !is_array($_POST['IndexColumnList'])
                                                || sizeof($_POST['IndexColumnList']) == 0) addPrimaryOrUniqueKey($_POST['type'], true, $lang['struniqneedscols']);
                                else {
-                                       $status = $localData->addUniqueKey($_POST['table'], $_POST['IndexColumnList'], $_POST['name']);
+                                       $status = $data->addUniqueKey($_POST['table'], $_POST['IndexColumnList'], $_POST['name']);
                                        if ($status == 0)
                                                doDefault($lang['struniqadded']);
                                        else
         * Confirm and then actually add a CHECK constraint
         */
        function addCheck($confirm, $msg = '') {
-               global $PHP_SELF, $data, $localData, $misc;
+               global $PHP_SELF, $data, $data, $misc;
                global $lang;
 
                if (!isset($_POST['name'])) $_POST['name'] = '';
                        if (trim($_POST['definition']) == '')
                                addCheck(true, $lang['strcheckneedsdefinition']);
                        else {
-                               $status = $localData->addCheckConstraint($_POST['table'],
+                               $status = $data->addCheckConstraint($_POST['table'],
                                        $_POST['definition'], $_POST['name']);
                                if ($status == 0)
                                        doDefault($lang['strcheckadded']);
         * Show confirmation of drop and perform actual drop
         */
        function doDrop($confirm) {
-               global $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                if ($confirm) {
                        echo "<input type=\"hidden\" name=\"type\" value=\"", htmlspecialchars($_REQUEST['type']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"choice\" value=\"{$lang['stryes']}\" />\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropConstraint($_POST['constraint'], $_POST['table'], $_POST['type'], isset($_POST['cascade']));
+                       $status = $data->dropConstraint($_POST['constraint'], $_POST['table'], $_POST['type'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strconstraintdropped']);
                        else
         * List all the constraints on the table
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF;
                global $lang;
 
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strconstraints']}</h2>\n";
                $misc->printMsg($msg);
 
-               $constraints = &$localData->getConstraints($_REQUEST['table']);
+               $constraints = &$data->getConstraints($_REQUEST['table']);
 
                if ($constraints->recordCount() > 0) {
                        echo "<table>\n";
                                if ($constraints->f['consrc'] !== null)
                                        echo $misc->printVal($constraints->f[$data->cnFields['consrc']]);
                                else {
-                                       $atts = &$localData->getKeys($_REQUEST['table'], explode(' ', $constraints->f['indkey']));
+                                       $atts = &$data->getKeys($_REQUEST['table'], explode(' ', $constraints->f['indkey']));
                                        echo ($constraints->f['contype'] == 'u') ? "UNIQUE (" : "PRIMARY KEY (";
                                        echo join(',', $atts);
                                        echo ")";
index 3ac2735e1e004b19ed2ab640c74c066a91ea42ee..a2b8b86a17583986aa90700f5460b858ba3dba80 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage conversions in a database
         *
-        * $Id: conversions.php,v 1.1 2003/10/27 06:37:25 chriskl Exp $
+        * $Id: conversions.php,v 1.2 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
         * Show default list of conversions in the database
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc, $database;
+               global $data, $misc, $database;
                global $PHP_SELF, $lang;
 
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strconversions']}</h2>\n";
                $misc->printMsg($msg);
                
-               $conversions = &$localData->getconversions();
+               $conversions = &$data->getconversions();
 
                if ($conversions->recordCount() > 0) {
                        echo "<table>\n";
index 1269f04fe5097288ac487ac4ce9d0edf32ebb8d2..9b3efac153615ed0829ad814bd77882b6fa5fefa 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.25 2003/11/15 11:09:32 chriskl Exp $
+        * $Id: database.php,v 1.26 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -21,7 +21,7 @@
         * Searches for a named database object
         */
        function doFind($confirm = true, $msg = '') {
-               global $PHP_SELF, $data, $localData, $misc;
+               global $PHP_SELF, $data, $data, $misc;
                global $lang;
 
                if (!isset($_GET['term'])) $_GET['term'] = '';
@@ -41,7 +41,7 @@
                // If a search term has been specified, then perform the search
                // and display the results, grouped by object type
                if ($_GET['term'] != '') {
-                       $rs = &$localData->findObject($_GET['term']);
+                       $rs = &$data->findObject($_GET['term']);
                        if ($rs->recordCount() > 0) {
                                $curr = '';
                                while (!$rs->EOF) {
                                        }
                                        
                                        // Generate schema prefix
-                                       if ($localData->hasSchemas())
+                                       if ($data->hasSchemas())
                                                $prefix = $rs->f['schemaname'] . '.';
                                        else
                                                $prefix = '';
         * Allow database administration and tuning tasks
         */
        function doAdmin($action = '', $msg = '') {
-               global $PHP_SELF, $localData, $misc;
+               global $PHP_SELF, $data, $misc;
                global $lang;
 
                switch ($action) {
                        case 'vacuum':
-                               $status = $localData->vacuumDB();
+                               $status = $data->vacuumDB();
                                if ($status == 0) doAdmin('', $lang['strvacuumgood']);
                                else doAdmin('', $lang['strvacuumbad']);
                                break;
                        case 'analyze':
-                               $status = $localData->analyzeDB();
+                               $status = $data->analyzeDB();
                                if ($status == 0) doAdmin('', $lang['stranalyzegood']);
                                else doAdmin('', $lang['stranalyzebad']);
                                break;
         * Allow execution of arbitrary SQL statements on a database
         */
        function doSQL() {
-               global $PHP_SELF, $localData, $misc;
+               global $PHP_SELF, $data, $misc;
                global $lang;
 
                if (!isset($_REQUEST['query'])) $_REQUEST['query'] = '';
         * Show confirmation of drop and perform actual drop
         */
        function doDrop($confirm) {
-               global $PHP_SELF, $data, $localData, $misc;
+               global $PHP_SELF, $data, $data, $misc;
                global $lang, $_reload_browser;
 
                if ($confirm) {
                        echo "<input type=\"hidden\" name=\"database\" value=\"", htmlspecialchars($_REQUEST['database']), "\" />\n";
                        echo "<input type=\"hidden\" name=\"schema\" value=\"", htmlspecialchars($_REQUEST['schema']), "\" />\n";
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropSchema($_POST['schema'], isset($_POST['cascade']));
+                       $status = $data->dropSchema($_POST['schema'], isset($_POST['cascade']));
                        if ($status == 0) {
                                $_reload_browser = true;
                                doDefault($lang['strschemadropped']);
         * Actually creates the new schema in the database
         */
        function doSaveCreate() {
-               global $localData, $lang, $_reload_browser;
+               global $data, $lang, $_reload_browser;
 
                // Check that they've given a name
                if ($_POST['formName'] == '') doCreate($lang['strschemaneedsname']);
                else {
-                       $status = $localData->createSchema($_POST['formName'], $_POST['formAuth']);
+                       $status = $data->createSchema($_POST['formName'], $_POST['formAuth']);
                        if ($status == 0) {
                                $_reload_browser = true;
                                doDefault($lang['strschemacreated']);
         * Show default list of schemas in the server
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
                
                $misc->printDatabaseNav();
                
                // Check that the DB actually supports schemas
                if ($data->hasSchemas()) {
-                       $schemas = &$localData->getSchemas();
+                       $schemas = &$data->getSchemas();
 
                        if ($schemas->recordCount() > 0) {
                                echo "<table>\n";
index a21eeda0a23cf63ba71f3af17c418182d5f25f2b..86cf7b239e42171c05c43f83404eb921d63b5110 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Does an export to the screen or as a download
         *
-        * $Id: dataexport.php,v 1.5 2003/10/12 13:08:59 soranzo Exp $
+        * $Id: dataexport.php,v 1.6 2003/12/10 16:03:29 chriskl Exp $
         */
 
        $extensions = array(
                if (isset($_REQUEST['query'])) $_REQUEST['query'] = trim(unserialize($_REQUEST['query']));
 
                // Set up the dump transaction
-               $status = $localData->beginDump();
+               $status = $data->beginDump();
 
                // If the dump is not dataonly then dump the structure prefix
                if ($_REQUEST['what'] != 'dataonly')
-                       echo $localData->getTableDefPrefix($_REQUEST['table'], isset($clean));
+                       echo $data->getTableDefPrefix($_REQUEST['table'], isset($clean));
 
                // If the dump is not structureonly then dump the actual data
                if ($_REQUEST['what'] != 'structureonly') {
                        // Get database encoding
-                       $dbEncoding = $localData->getDatabaseEncoding();
+                       $dbEncoding = $data->getDatabaseEncoding();
 
                        // Set fetch mode to NUM so that duplicate field names are properly returned
-                       $localData->conn->setFetchMode(ADODB_FETCH_NUM);
+                       $data->conn->setFetchMode(ADODB_FETCH_NUM);
 
                        // Execute the query, if set, otherwise grab all rows from the table
                        if (isset($_REQUEST['table']))
-                               $rs = &$localData->dumpRelation($_REQUEST['table'], isset($oids));
+                               $rs = &$data->dumpRelation($_REQUEST['table'], isset($oids));
                        else
-                               $rs = $localData->conn->Execute($_REQUEST['query']);
+                               $rs = $data->conn->Execute($_REQUEST['query']);
 
                        if ($format == 'copy') {
                                $data->fieldClean($_REQUEST['table']);
                                echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n";
                                echo "<head>\r\n";
                                echo "\t<title></title>\r\n";
-                               echo "\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$localData->codemap[$dbEncoding]}\" />\r\n";
+                               echo "\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$data->codemap[$dbEncoding]}\" />\r\n";
                                echo "</head>\r\n";
                                echo "<body>\r\n";
                                echo "<table class=\"phppgadmin\">\r\n";
                                        $j = 0;
                                        foreach ($rs->f as $k => $v) {
                                                $finfo = $rs->fetchField($j++);
-                                               if ($finfo->name == $localData->id && !isset($oids)) continue;
+                                               if ($finfo->name == $data->id && !isset($oids)) continue;
                                                echo "\t\t<th>", $misc->printVal($finfo->name, true), "</th>\r\n";
                                        }
                                }
                                        $j = 0;
                                        foreach ($rs->f as $k => $v) {
                                                $finfo = $rs->fetchField($j++);
-                                               if ($finfo->name == $localData->id && !isset($oids)) continue;
+                                               if ($finfo->name == $data->id && !isset($oids)) continue;
                                                echo "\t\t<td>", $misc->printVal($v, true, $finfo->type), "</td>\r\n";
                                        }
                                        echo "\t</tr>\r\n";
                        }
                        elseif ($format == 'xml') {
                                echo "<?xml version=\"1.0\"";
-                               if (isset($localData->codemap[$dbEncoding]))
-                                       echo " encoding=\"{$localData->codemap[$dbEncoding]}\"";
+                               if (isset($data->codemap[$dbEncoding]))
+                                       echo " encoding=\"{$data->codemap[$dbEncoding]}\"";
                                echo " ?>\n";
                                echo "<data>\n";
                                if (!$rs->EOF) {
                                                $finfo = $rs->fetchField($j++);
                                                $k = $finfo->name;
                                                // SQL (INSERT) format cannot handle oids
-       //                                              if ($k == $localData->id) continue;
+       //                                              if ($k == $data->id) continue;
                                                // Output field
                                                $data->fieldClean($k);
                                                if ($first) echo "\"{$k}\"";
                // If the dump is not dataonly then dump the structure suffix
                if ($_REQUEST['what'] != 'dataonly') {
                        // Set fetch mode back to ASSOC for the table suffix to work
-                       $localData->conn->setFetchMode(ADODB_FETCH_ASSOC);
-                       echo $localData->getTableDefSuffix($_REQUEST['table']);
+                       $data->conn->setFetchMode(ADODB_FETCH_ASSOC);
+                       echo $data->getTableDefSuffix($_REQUEST['table']);
                }
 
                // Finish the dump transaction
-               $status = $localData->endDump();
+               $status = $data->endDump();
        }
        else {
                if (!isset($msg)) $msg = null;
index 4adef2a13f35829063223ad53d7a79851176b631..6c08a920e9b33c3dbe01bd93de2c96eb76ea2d55 100644 (file)
@@ -9,7 +9,7 @@
         * @param $return_desc The return link name
         * @param $page The current page
         *
-        * $Id: display.php,v 1.32 2003/11/26 06:06:49 chriskl Exp $
+        * $Id: display.php,v 1.33 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -24,7 +24,7 @@
         * Show confirmation of edit and perform actual update
         */
        function doEditRow($confirm, $msg = '') {
-               global $localData, $database, $misc;
+               global $database, $misc;
                global $lang;
                global $PHP_SELF;
 
@@ -34,8 +34,8 @@
                        echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: ", $misc->printVal($_REQUEST['table']), ": {$lang['streditrow']}</h2>\n";
                        $misc->printMsg($msg);
 
-                       $attrs = &$localData->getTableAttributes($_REQUEST['table']);
-                       $rs = &$localData->browseRow($_REQUEST['table'], $key);
+                       $attrs = &$data->getTableAttributes($_REQUEST['table']);
+                       $rs = &$data->browseRow($_REQUEST['table'], $key);
 
                        echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
                        $error = true;                  
@@ -49,7 +49,7 @@
 
                                $i = 0;
                                while (!$attrs->EOF) {
-                                       $attrs->f['attnotnull'] = $localData->phpBool($attrs->f['attnotnull']);
+                                       $attrs->f['attnotnull'] = $data->phpBool($attrs->f['attnotnull']);
                                        $id = (($i % 2) == 0 ? '1' : '2');
                                        
                                        // Initialise variables
@@ -59,7 +59,7 @@
                                        echo "<tr>\n";
                                        echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($attrs->f['attname']), "</td>";
                                        echo "<td class=\"data{$id}\" nowrap=\"nowrap\">\n";
-                                       echo $misc->printVal($localData->formatType($attrs->f['type'], $attrs->f['atttypmod']));
+                                       echo $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod']));
                                        echo "<input type=\"hidden\" name=\"types[", htmlspecialchars($attrs->f['attname']), "]\" value=\"", 
                                                htmlspecialchars($attrs->f['type']), "\" /></td>";
                                        echo "<td class=\"data{$id}\" nowrap=\"nowrap\">\n";
@@ -80,7 +80,7 @@
                                        else
                                                echo "&nbsp;</td>";
 
-                                       echo "<td class=\"data{$id}\" nowrap>", $localData->printField("values[{$attrs->f['attname']}]",
+                                       echo "<td class=\"data{$id}\" nowrap>", $data->printField("values[{$attrs->f['attname']}]",
                                                $rs->f[$attrs->f['attname']], $attrs->f['type']), "</td>";
                                        echo "</tr>\n";
                                        $i++;
                        if (!isset($_POST['values'])) $_POST['values'] = array();
                        if (!isset($_POST['nulls'])) $_POST['nulls'] = array();
                        
-                       $status = $localData->editRow($_POST['table'], $_POST['values'], $_POST['nulls'], 
+                       $status = $data->editRow($_POST['table'], $_POST['values'], $_POST['nulls'], 
                                                                                                $_POST['format'], $_POST['types'], unserialize($_POST['key']));
                        if ($status == 0)
                                doBrowse($lang['strrowupdated']);
         * Show confirmation of drop and perform actual drop
         */
        function doDelRow($confirm) {
-               global $localData, $database, $misc;
+               global $database, $misc;
                global $lang;
                global $PHP_SELF;
 
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->deleteRow($_POST['table'], unserialize($_POST['key']));
+                       $status = $data->deleteRow($_POST['table'], unserialize($_POST['key']));
                        if ($status == 0)
                                doBrowse($lang['strrowdeleted']);
                        elseif ($status == -2)
         * Displays requested data
         */
        function doBrowse() {
-               global $localData, $conf, $misc, $lang;
+               global $data, $conf, $misc, $lang;
                
                // If current page is not set, default to first page
                if (!isset($_REQUEST['page'])) $_REQUEST['page'] = 1;
        
                // Fetch unique row identifier, if this is a table browse request.
                if (isset($_REQUEST['table']))
-                       $key = $localData->getRowIdentifier($_REQUEST['table']);
+                       $key = $data->getRowIdentifier($_REQUEST['table']);
                else
                        $key = array();
                
                // Retrieve page from query.  $max_pages is returned by reference.
-               $rs = &$localData->browseQuery($type, 
+               $rs = &$data->browseQuery($type, 
                        isset($_REQUEST['table']) ? $_REQUEST['table'] : null, 
                        isset($_REQUEST['query']) ? $_REQUEST['query'] : null, 
                        $_REQUEST['sortkey'], $_REQUEST['sortdir'], $_REQUEST['page'],
 
                        $j = 0;         
                        foreach ($rs->f as $k => $v) {
-                               if (isset($_REQUEST['table']) && $k == $localData->id && !$conf['show_oids']) {
+                               if (isset($_REQUEST['table']) && $k == $data->id && !$conf['show_oids']) {
                                        $j++;
                                        continue;
                                }
                                $finfo = $rs->fetchField($j);
                                // Display column headers with sorting options, unless we're PostgreSQL
                                // 7.0 and it's a non-TABLE mode
-                               if (!$localData->hasFullSubqueries() && $type != 'TABLE') {
+                               if (!$data->hasFullSubqueries() && $type != 'TABLE') {
                                        echo "<th class=\"data\">", $misc->printVal($finfo->name), "</th>\n";
                                }
                                else {
                                $j = 0;
                                foreach ($rs->f as $k => $v) {
                                        $finfo = $rs->fetchField($j++);
-                                       if (isset($_REQUEST['table']) && $k == $localData->id && !$conf['show_oids']) continue;
+                                       if (isset($_REQUEST['table']) && $k == $data->id && !$conf['show_oids']) continue;
                                        elseif ($v !== null && $v == '') echo "<td class=\"data{$id}\">&nbsp;</td>";
                                        else {
                                                // Trim strings if over length
index 4cd9748e87bf358848cf2b278999fe1dccc55b66..a6197f7bf1c8e515c9262d0fc303a6d74ea6cf4d 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage domains in a database
         *
-        * $Id: domains.php,v 1.5 2003/09/09 06:23:12 chriskl Exp $
+        * $Id: domains.php,v 1.6 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -17,9 +17,9 @@
         * Function to save after altering a domain
         */
        function doSaveAlter() {
-               global $localData, $lang;
+               global $data, $lang;
                
-               $status = $localData->alterDomain($_POST['domain'], $_POST['domdefault'], 
+               $status = $data->alterDomain($_POST['domain'], $_POST['domdefault'], 
                        isset($_POST['domnotnull']), $_POST['domowner']);
                if ($status == 0)
                        doProperties($lang['strdomainaltered']);
         * Allow altering a domain
         */
        function doAlter($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
        
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}: ", $misc->printVal($_REQUEST['domain']), ": {$lang['stralter']}</h2>\n";
                $misc->printMsg($msg);
                
                // Fetch domain info
-               $domaindata = &$localData->getDomain($_REQUEST['domain']);
+               $domaindata = &$data->getDomain($_REQUEST['domain']);
                // Fetch all users
                $users = &$data->getUsers();
                
@@ -87,7 +87,7 @@
         * Confirm and then actually add a CHECK constraint
         */
        function addCheck($confirm, $msg = '') {
-               global $PHP_SELF, $data, $localData, $misc;
+               global $PHP_SELF, $data, $data, $misc;
                global $lang;
 
                if (!isset($_POST['name'])) $_POST['name'] = '';
                        if (trim($_POST['definition']) == '')
                                addCheck(true, $lang['strcheckneedsdefinition']);
                        else {
-                               $status = $localData->addDomainCheckConstraint($_POST['domain'],
+                               $status = $data->addDomainCheckConstraint($_POST['domain'],
                                        $_POST['definition'], $_POST['name']);
                                if ($status == 0)
                                        doProperties($lang['strcheckadded']);
         * Show confirmation of drop constraint and perform actual drop
         */
        function doDropConstraint($confirm, $msg = '') {
-               global $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                if ($confirm) { 
                        echo "<input type=\"hidden\" name=\"constraint\" value=\"", htmlspecialchars($_REQUEST['constraint']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropDomainConstraint($_POST['domain'], $_POST['constraint'], isset($_POST['cascade']));
+                       $status = $data->dropDomainConstraint($_POST['domain'], $_POST['constraint'], isset($_POST['cascade']));
                        if ($status == 0)
                                doProperties($lang['strconstraintdropped']);
                        else
         * Show properties for a domain.  Allow manipulating constraints as well.
         */
        function doProperties($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
        
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}: ", $misc->printVal($_REQUEST['domain']), ": {$lang['strproperties']}</h2>\n";
                $misc->printMsg($msg);
                
-               $domaindata = &$localData->getDomain($_REQUEST['domain']);
+               $domaindata = &$data->getDomain($_REQUEST['domain']);
                
                if ($domaindata->recordCount() > 0) {
                        // Display domain info
                        
                        // Display domain constraints
                        if ($data->hasDomainConstraints()) {
-                               $domaincons = &$localData->getDomainConstraints($_REQUEST['domain']);
+                               $domaincons = &$data->getDomainConstraints($_REQUEST['domain']);
                                if ($domaincons->recordCount() > 0) {
                                        echo "<h3>{$lang['strconstraints']}</h3>\n";
                                        echo "<table>\n";
         * Show confirmation of drop and perform actual drop
         */
        function doDrop($confirm) {
-               global $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                if ($confirm) { 
                        echo "<input type=\"hidden\" name=\"domain\" value=\"", htmlspecialchars($_REQUEST['domain']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropDomain($_POST['domain'], isset($_POST['cascade']));
+                       $status = $data->dropDomain($_POST['domain'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strdomaindropped']);
                        else
         * Displays a screen where they can enter a new domain
         */
        function doCreate($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
                
                if (!isset($_POST['domname'])) $_POST['domname'] = '';
                if (!isset($_POST['domdefault'])) $_POST['domdefault'] = '';
                if (!isset($_POST['domcheck'])) $_POST['domcheck'] = '';
 
-               $types = &$localData->getTypes(true);
+               $types = &$data->getTypes(true);
                
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}: {$lang['strcreatedomain']}</h2>\n";
                $misc->printMsg($msg);
         * Actually creates the new domain in the database
         */
        function doSaveCreate() {
-               global $localData, $lang;
+               global $data, $lang;
                
                if (!isset($_POST['domcheck'])) $_POST['domcheck'] = '';
 
                // Check that they've given a name and a definition
                if ($_POST['domname'] == '') doCreate($lang['strdomainneedsname']);
                else {           
-                       $status = $localData->createDomain($_POST['domname'], $_POST['domtype'], 
+                       $status = $data->createDomain($_POST['domname'], $_POST['domtype'], 
                                                                                                                                isset($_POST['domnotnull']), $_POST['domdefault'], $_POST['domcheck']);
                        if ($status == 0)
                                doDefault($lang['strdomaincreated']);
         * Show default list of domains in the database
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
                
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strdomains']}</h2>\n";
                $misc->printMsg($msg);
                
-               $domains = &$localData->getDomains();
+               $domains = &$data->getDomains();
                
                if ($domains->recordCount() > 0) {
                        echo "<table>\n";
index 760bb6b945e986656b43be89f403a05dcc2b4ac4..36f2aed47ea64df7529bf98831d9e05f998e46f4 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage functions in a database
         *
-        * $Id: functions.php,v 1.22 2003/10/27 05:43:18 chriskl Exp $
+        * $Id: functions.php,v 1.23 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -17,9 +17,9 @@
         * Function to save after editing a function
         */
        function doSaveEdit() {
-               global $localData, $lang;
+               global $data, $lang;
 
-               $status = $localData->setFunction($_POST['function_oid'], $_POST['original_function'], $_POST['original_arguments'], 
+               $status = $data->setFunction($_POST['function_oid'], $_POST['original_function'], $_POST['original_arguments'], 
                                                                                                                $_POST['original_returns'], $_POST['formDefinition'], 
                                                                                                                $_POST['original_lang'], $_POST['formProperties'], isset($_POST['original_setof']), true);
                if ($status == 0)
         * Function to allow editing of a Function
         */
        function doEdit($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
                
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strfunctions']}: ", $misc->printVal($_REQUEST['function']), ": {$lang['stralter']}</h2>\n";
                $misc->printMsg($msg);
 
-               $fndata = &$localData->getFunction($_REQUEST['function_oid']);
+               $fndata = &$data->getFunction($_REQUEST['function_oid']);
 
                if ($fndata->recordCount() > 0) {
                        $fndata->f[$data->fnFields['setof']] = $data->phpBool($fndata->f[$data->fnFields['setof']]);
 
                        // Initialise variables
                        if (!isset($_POST['formDefinition'])) $_POST['formDefinition'] = $fndata->f[$data->fnFields['fndef']];
-                       if (!isset($_POST['formProperties'])) $_POST['formProperties'] = $localData->getFunctionProperties($fndata->f);
+                       if (!isset($_POST['formProperties'])) $_POST['formProperties'] = $data->getFunctionProperties($fndata->f);
 
                        $func_full = $fndata->f[$data->fnFields['fnname']] . "(". $fndata->f[$data->fnFields['fnarguments']] .")";
                        echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
         * Show read only properties of a function
         */
        function doProperties($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
        
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strfunctions']}: ", $misc->printVal($_REQUEST['function']), ": {$lang['strproperties']}</h2>\n";
                $misc->printMsg($msg);
                
-               $funcdata = &$localData->getFunction($_REQUEST['function_oid']);
+               $funcdata = &$data->getFunction($_REQUEST['function_oid']);
                
                if ($funcdata->recordCount() > 0) {
                        $funcdata->f[$data->fnFields['setof']] = $data->phpBool($funcdata->f[$data->fnFields['setof']]);
                        echo "<tr><td class=\"data1\" colspan=\"4\">", $misc->printVal($funcdata->f[$data->fnFields['fndef']]), "</td></tr>\n";
                        if (is_array($data->funcprops) && sizeof($data->funcprops) > 0) {
                                // Fetch an array of the function properties
-                               $funcprops = $localData->getFunctionProperties($funcdata->f);
+                               $funcprops = $data->getFunctionProperties($funcdata->f);
                                echo "<tr><th class=\"data\" colspan=\"4\">{$lang['strproperties']}</th></tr>\n";
                                echo "<tr><td class=\"data1\" colspan=\"4\">\n";
                                foreach ($funcprops as $v) {
         * Show confirmation of drop and perform actual drop
         */
        function doDrop($confirm) {
-               global $localData, $database, $misc;
+               global $database, $misc;
                global $PHP_SELF, $lang;
 
                if ($confirm) { 
                        echo "<input type=\"hidden\" name=\"function_oid\" value=\"", htmlspecialchars($_REQUEST['function_oid']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropFunction($_POST['function_oid'], isset($_POST['cascade']));
+                       $status = $data->dropFunction($_POST['function_oid'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strfunctiondropped']);
                        else
         * Displays a screen where they can enter a new function
         */
        function doCreate($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
                
                if (!isset($_POST['formFunction'])) $_POST['formFunction'] = '';
                if (!isset($_POST['formProperties'])) $_POST['formProperties'] = $data->defaultprops;
                if (!isset($_POST['formSetOf'])) $_POST['formSetOf'] = '';
                
-               $types = &$localData->getTypes(true);
-               $langs = &$localData->getLanguages(true);
+               $types = &$data->getTypes(true);
+               $langs = &$data->getLanguages(true);
 
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strfunctions']}: {$lang['strcreatefunction']}</h2>\n";
                $misc->printMsg($msg);
         * Actually creates the new function in the database
         */
        function doSaveCreate() {
-               global $localData, $lang;
+               global $data, $lang;
                
                // Set properties to an empty array if it doesn't exist (for db's without properties)
                if (!is_array($_POST['formProperties'])) $_POST['formProperties'] = array();
                if ($_POST['formFunction'] == '') doCreate($lang['strfunctionneedsname']);
                elseif ($_POST['formDefinition'] == '') doCreate($lang['strfunctionneedsdef']);
                else {           
-                       $status = $localData->createFunction($_POST['formFunction'], $_POST['formArguments'] , 
+                       $status = $data->createFunction($_POST['formFunction'], $_POST['formArguments'] , 
                                        $_POST['formReturns'] , $_POST['formDefinition'] , $_POST['formLanguage'], 
                                        $_POST['formProperties'], $_POST['formSetOf'] == 'SETOF', false);
                        if ($status == 0)
         * Show default list of functions in the database
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc, $func;
+               global $data, $misc, $func;
                global $PHP_SELF, $lang;
                
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strfunctions']}</h2>\n";
                $misc->printMsg($msg);
                
-               $funcs = &$localData->getFunctions();
+               $funcs = &$data->getFunctions();
 
                if ($funcs->recordCount() > 0) {
                        echo "<table>\n";
index 302ea206ec62b7ea578c9c5c03dcd422d8b933f1..b45db1657fbf9a640b18ede1bd8a5c26f665c991 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List indexes on a table
         *
-        * $Id: indexes.php,v 1.19 2003/10/08 02:14:24 chriskl Exp $
+        * $Id: indexes.php,v 1.20 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -17,7 +17,7 @@
         * Show confirmation of cluster index and perform actual cluster
         */
        function doClusterIndex($confirm) {
-               global $localData, $database, $misc, $action;
+               global $database, $misc, $action;
                global $PHP_SELF, $lang;
 
                if ($confirm) {
@@ -40,7 +40,7 @@
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->clusterIndex($_POST['index'], $_POST['table'], isset($_POST['analyze']));
+                       $status = $data->clusterIndex($_POST['index'], $_POST['table'], isset($_POST['analyze']));
                        if ($status == 0)
                                doDefault($lang['strclusteredgood'] . ((isset($_POST['analyze']) ? ' ' . $lang['stranalyzegood'] : '')));
                        else
@@ -53,7 +53,7 @@
         * Displays a screen where they can enter a new index
         */
        function doCreateIndex($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                if (!isset($_POST['formIndexName'])) $_POST['formIndexName'] = '';
@@ -64,7 +64,7 @@
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strindexes']}: {$lang['strcreateindex']} </h2>\n";
                $misc->printMsg($msg);
 
-               $attrs = &$localData->getTableAttributes($_REQUEST['table']);
+               $attrs = &$data->getTableAttributes($_REQUEST['table']);
 
                $selColumns = new XHTML_select("TableColumnList",true,10);
                $selColumns->set_style("width: 10em;");
                echo "<tr>";
                echo "<th class=\"data\">{$lang['strindextype']}</th>";
                echo "<td class=\"data1\"><select name=\"formIndexType\">";
-               foreach ($localData->typIndexes as $v) {
+               foreach ($data->typIndexes as $v) {
                        echo "<option value=\"", htmlspecialchars($v), "\"",
                                ($v == $_POST['formIndexType']) ? ' selected="selected"' : '', ">", htmlspecialchars($v), "</option>\n";
                }
         * @@ Note: this function can't handle columns with commas in them
         */
        function doSaveCreateIndex() {
-               global $localData;
+               global $data;
                global $lang;
                
                // Handle databases that don't have partial indexes
                if ($_POST['formIndexName'] == '') doCreateIndex($lang['strindexneedsname']);
                elseif (!isset($_POST['IndexColumnList']) || $_POST['IndexColumnList'] == '') doCreateIndex($lang['strindexneedscols']);
                else {
-                       $status = $localData->createIndex($_POST['formIndexName'], $_POST['table'], $_POST['IndexColumnList'], 
+                       $status = $data->createIndex($_POST['formIndexName'], $_POST['table'], $_POST['IndexColumnList'], 
                                $_POST['formIndexType'], isset($_POST['formUnique']), $_POST['formWhere']);
                        if ($status == 0)
                                doDefault($lang['strindexcreated']);
         * Show confirmation of drop index and perform actual drop
         */
        function doDropIndex($confirm) {
-               global $localData, $database, $misc;
+               global $database, $misc;
                global $PHP_SELF, $lang;
 
                if ($confirm) {
                        echo "<input type=\"hidden\" name=\"index\" value=\"", htmlspecialchars($_REQUEST['index']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropIndex($_POST['index'], isset($_POST['cascade']));
+                       $status = $data->dropIndex($_POST['index'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strindexdropped']);
                        else
        }
 
        function doDefault($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                $misc->printTableNav();
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strindexes']}</h2>\n";
                $misc->printMsg($msg);
 
-               $indexes = &$localData->getIndexes($_REQUEST['table']);
+               $indexes = &$data->getIndexes($_REQUEST['table']);
                
                if ($indexes->recordCount() > 0) {
                        echo "<table>\n";
index aa3f6a94316bdf97fac3234d6d6086ce060e9a37..7b8512a9b0264858383c88585ccc395f00798785 100644 (file)
--- a/info.php
+++ b/info.php
@@ -3,7 +3,7 @@
        /**
         * List extra information on a table
         *
-        * $Id: info.php,v 1.2 2003/10/13 01:42:04 chriskl Exp $
+        * $Id: info.php,v 1.3 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -16,7 +16,7 @@
         * List all the information on the table
         */
        function doDefault($msg = '') {
-               global $localData, $misc;
+               global $data, $misc;
                global $lang;
 
                $misc->printTableNav();
@@ -24,9 +24,9 @@
                $misc->printMsg($msg);
 
                // Fetch info
-               $referrers = &$localData->getReferrers($_REQUEST['table']);
-               $parents = &$localData->getTableParents($_REQUEST['table']);
-               $children = &$localData->getTableChildren($_REQUEST['table']);
+               $referrers = &$data->getReferrers($_REQUEST['table']);
+               $parents = &$data->getTableParents($_REQUEST['table']);
+               $children = &$data->getTableChildren($_REQUEST['table']);
 
                // Check that there is some info
                if (($referrers === -99 || ($referrers !== -99 && $referrers->recordCount() == 0)) 
@@ -39,7 +39,7 @@
                                echo "<h3>{$lang['strreferringtables']}</h3>\n";
                                echo "<table>\n";
                                echo "\t<tr>\n\t\t";
-                               if ($localData->hasSchemas()) {
+                               if ($data->hasSchemas()) {
                                        echo "<th class=\"data\">{$lang['strschema']}</th>";
                                }
                                echo "<th class=\"data\">{$lang['strtable']}</th>";
@@ -51,7 +51,7 @@
                                while (!$referrers->EOF) {
                                        $id = ( ($i % 2 ) == 0 ? '1' : '2' );
                                        echo "\t<tr>\n\t\t";
-                                       if ($localData->hasSchemas()) {
+                                       if ($data->hasSchemas()) {
                                                echo "<td class=\"data{$id}\">", $misc->printVal($referrers->f['nspname']), "</td>";
                                        }
                                        echo "<td class=\"data{$id}\">", $misc->printVal($referrers->f['relname']), "</td>";
@@ -73,7 +73,7 @@
                                echo "<h3>{$lang['strparenttables']}</h3>\n";
                                echo "<table>\n";
                                echo "\t<tr>\n\t\t";
-                               if ($localData->hasSchemas()) {                 
+                               if ($data->hasSchemas()) {                      
                                        echo "<th class=\"data\">{$lang['strschema']}</th>";
                                }
                                echo "\t\t<th class=\"data\">{$lang['strtable']}</th>";                 
@@ -84,7 +84,7 @@
                                while (!$parents->EOF) {
                                        $id = ( ($i % 2 ) == 0 ? '1' : '2' );
                                        echo "\t<tr>\n";
-                                       if ($localData->hasSchemas()) {
+                                       if ($data->hasSchemas()) {
                                                echo "\t\t<td class=\"data{$id}\">", $misc->printVal($parents->f['schemaname']), "</td>";
                                        }
                                        echo "<td class=\"data{$id}\">", $misc->printVal($parents->f['relname']), "</td>";
                                echo "<h3>{$lang['strchildtables']}</h3>\n";
                                echo "<table>\n";
                                echo "\t<tr>\n";
-                               if ($localData->hasSchemas()) {                 
+                               if ($data->hasSchemas()) {                      
                                        echo "<th class=\"data\">{$lang['strschema']}</th>";
                                }
                                echo "\t\t<th class=\"data\">{$lang['strtable']}</th>";                 
                                while (!$children->EOF) {
                                        $id = ( ($i % 2 ) == 0 ? '1' : '2' );
                                        echo "\t<tr>\n";
-                                       if ($localData->hasSchemas()) {
+                                       if ($data->hasSchemas()) {
                                                echo "\t\t<td class=\"data{$id}\">", $misc->printVal($children->f['schemaname']), "</td>";
                                        }
                                        echo "<td class=\"data{$id}\">", $misc->printVal($children->f['relname']), "</td>";
index 4b52721587c4c975452051e083b8db683f23d719..8aca7404f22d6e91a413d8fb0a54318d1365c02a 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage languages in a database
         *
-        * $Id: languages.php,v 1.1 2003/10/27 06:37:25 chriskl Exp $
+        * $Id: languages.php,v 1.2 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
         * Show default list of languages in the database
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc, $database;
+               global $data, $misc, $database;
                global $PHP_SELF, $lang;
 
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strlanguages']}</h2>\n";
                $misc->printMsg($msg);
                
-               $languages = &$localData->getlanguages();
+               $languages = &$data->getlanguages();
 
                if ($languages->recordCount() > 0) {
                        echo "<table>\n";
index cf606b2e1930d96348d5e9e008a4272dcb2f8f1b..5577b5f2583383237f5e59589f45bbce35338d7f 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Function library read in upon startup
         *
-        * $Id: lib.inc.php,v 1.68 2003/11/28 01:20:38 chriskl Exp $
+        * $Id: lib.inc.php,v 1.69 2003/12/10 16:03:30 chriskl Exp $
         */
        
        // Set error reporting level to max
@@ -13,7 +13,7 @@
        $appName = 'phpPgAdmin';
 
        // Application version
-       $appVersion = '3.2';
+       $appVersion = '3.3-dev';
 
 
        // Check to see if the configuration file exists, if not, explain
        // Import language file
        include("lang/recoded/" . strtolower($_SESSION['webdbLanguage']) . ".php");
 
-       // Create data accessor object, if valid, and if necessary
+       // Check database support is properly compiled in
+       if (!function_exists('pg_connect')) {
+               echo $lang['strnotloaded'];
+               exit;
+       }
+
+       // Create data accessor object, if necessary
        if (!isset($_no_db_connection)) {
-               if (isset($_SESSION['webdbServerID']) && isset($conf['servers'][$_SESSION['webdbServerID']])) {
-                       if (!isset($conf['servers'][$_SESSION['webdbServerID']]['type']))
-                               $conf['servers'][$_SESSION['webdbServerID']]['type'] = 'postgres7';
-                       $_type = $misc->getDriver($conf['servers'][$_SESSION['webdbServerID']]['host'],
-                                                       $conf['servers'][$_SESSION['webdbServerID']]['port'],
-                                                       $_SESSION['webdbUsername'],
-                                                       $_SESSION['webdbPassword'],
-                                                       $conf['servers'][$_SESSION['webdbServerID']]['type'],
-                                                       $conf['servers'][$_SESSION['webdbServerID']]['defaultdb'],
-                                                       $conf['description']);
-                       // Check return type
-                       if ($_type == -1) {
-                               echo $lang['strnotloaded'];
+               // Connect to the current database, or if one is not specified
+               // then connect to the default database.
+               if (isset($_REQUEST['database']))
+                       $_curr_db = $_REQUEST['database'];
+               else
+                       $_curr_db = $conf['servers'][$_SESSION['webdbServerID']]['defaultdb'];
+
+               // Create the connection object and make the connection
+               include_once('classes/database/Connection.php');
+               $_connection = new Connection(
+                       $conf['servers'][$_SESSION['webdbServerID']]['host'],
+                       $conf['servers'][$_SESSION['webdbServerID']]['port'],
+                       $_SESSION['webdbUsername'],
+                       $_SESSION['webdbPassword'],
+                       $_curr_db
+               );
+
+               // Get the name of the database driver we need to use.  The description
+               // of the server is returned and placed into the conf array.
+               $_type = $_connection->getDriver($conf['description']);
+               // XXX: NEED TO CHECK RETURN STATUS HERE
+
+               // Create a database wrapper class for easy manipulation of the
+               // connection.
+               require_once('classes/database/' . $_type . '.php');
+               $data = new $_type($_connection->conn);
+
+               // If schema is defined and database supports schemas, then set the 
+               // schema explicitly.
+               if (isset($_REQUEST['database']) && isset($_REQUEST['schema']) && $data->hasSchemas()) {
+                       $status = $data->setSchema($_REQUEST['schema']);
+                       if ($status != 0) {
+                               echo $lang['strbadschema'];
                                exit;
                        }
-                       // @@ NEED TO CHECK MORE RETURN VALS HERE
-
-                       require_once('classes/database/' . $_type . '.php');
-                       $data = new $_type($conf['servers'][$_SESSION['webdbServerID']]['host'],
-                                               $conf['servers'][$_SESSION['webdbServerID']]['port'],
-                                               $conf['servers'][$_SESSION['webdbServerID']]['defaultdb'],
-                                               $_SESSION['webdbUsername'],
-                                               $_SESSION['webdbPassword']);
-               }
-
-               // Create local (database-specific) data accessor object, if valid
-               if (isset($_SESSION['webdbServerID']) && isset($conf['servers'][$_SESSION['webdbServerID']]) && isset($_REQUEST['database'])) {
-                       require_once('classes/database/' . $_type . '.php');
-                       $localData = new $_type(        $conf['servers'][$_SESSION['webdbServerID']]['host'],
-                                                                                               $conf['servers'][$_SESSION['webdbServerID']]['port'],
-                                                                                               $_REQUEST['database'],
-                                                                                               $_SESSION['webdbUsername'],
-                                                                                               $_SESSION['webdbPassword']);
-
-                       // If schema is defined and database supports schemas, then set the schema explicitly
-                       if (isset($_REQUEST['schema']) && $localData->hasSchemas()) {
-                               $status = $localData->setSchema($_REQUEST['schema']);
-                               if ($status != 0) {
-                                       echo $lang['strbadschema'];
-                                       exit;
-                               }
-                       }
-
                }
-       }
 
-       // Get database encoding
-       if (isset($localData)) {
-               $dbEncoding = $localData->getDatabaseEncoding();
+               // Get database encoding
+               $dbEncoding = $data->getDatabaseEncoding();
                
                // Set client encoding to database encoding
                if ($dbEncoding != '') {
-                       $status = $localData->setClientEncoding($dbEncoding);
+                       $status = $data->setClientEncoding($dbEncoding);
                        if ($status != 0 && $status != -99) {
                                echo $lang['strbadencoding'];
                                exit;
                        }
                
                        // Override $lang['appcharset']
-                       if (isset($localData->codemap[$dbEncoding]))
-                               $lang['appcharset'] = $localData->codemap[$dbEncoding];
+                       if (isset($data->codemap[$dbEncoding]))
+                               $lang['appcharset'] = $data->codemap[$dbEncoding];
                        else
                                $lang['appcharset'] = $dbEncoding;
                }
        }
-       // This experiment didn't quite work - try again later.
-       /*
-       else {
-               $status = $data->setClientEncoding('UNICODE');
-               if ($status != 0) {
-                       echo $lang['strbadencoding'];
-                       exit;
-               }
-
-               // Override $lang['appcharset']
-               $lang['appcharset'] = $data->codemap['UNICODE'];
-       }
-       */
 
 ?>
index 0a9ae28e8cc440a8a66744ff18608d87be133282..50c7b4341bf0b955919f0d79b442f210549397e9 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage operators in a database
         *
-        * $Id: operators.php,v 1.7 2003/10/26 10:59:16 chriskl Exp $
+        * $Id: operators.php,v 1.8 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
         * Show read only properties for an operator
         */
        function doProperties($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['stroperators']}: ", $misc->printVal($_REQUEST['operator']), ": {$lang['strproperties']}</h2>\n";
                $misc->printMsg($msg);
                
-               $oprdata = &$localData->getOperator($_REQUEST['operator_oid']);
-               $oprdata->f['oprcanhash'] = $localData->phpBool($oprdata->f['oprcanhash']);
+               $oprdata = &$data->getOperator($_REQUEST['operator_oid']);
+               $oprdata->f['oprcanhash'] = $data->phpBool($oprdata->f['oprcanhash']);
 
                if ($oprdata->recordCount() > 0) {
                        echo "<table>\n";
@@ -66,7 +66,7 @@
         * Show confirmation of drop and perform actual drop
         */
        function doDrop($confirm) {
-               global $localData, $database, $misc;
+               global $database, $misc;
                global $PHP_SELF, $lang;
 
                if ($confirm) { 
@@ -80,7 +80,7 @@
                        echo "<input type=\"hidden\" name=\"operator_oid\" value=\"", htmlspecialchars($_REQUEST['operator_oid']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
@@ -88,7 +88,7 @@
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropOperator($_POST['operator_oid'], isset($_POST['cascade']));
+                       $status = $data->dropOperator($_POST['operator_oid'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['stroperatordropped']);
                        else
         * Show default list of operators in the database
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc, $database;
+               global $data, $misc, $database;
                global $PHP_SELF, $lang;
 
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['stroperators']}</h2>\n";
                $misc->printMsg($msg);
                
-               $operators = &$localData->getOperators();
+               $operators = &$data->getOperators();
 
                if ($operators->recordCount() > 0) {
                        echo "<table>\n";
index b9330e0833285744b80ca9be6b04c310d21e5aaa..fae8342db0f6df87735888e3006c5329bc1dfed8 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage privileges in a database
         *
-        * $Id: privileges.php,v 1.19 2003/09/09 06:23:12 chriskl Exp $
+        * $Id: privileges.php,v 1.20 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -19,7 +19,7 @@
         * @param $msg (optional) A message to show
         */
        function doAlter($confirm, $msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                if (!isset($_REQUEST['username'])) $_REQUEST['username'] = array();
@@ -29,7 +29,7 @@
                // Set name
                switch ($_REQUEST['type']) {
                        case 'function':
-                               $fn = &$localData->getFunction($_REQUEST['object']);
+                               $fn = &$data->getFunction($_REQUEST['object']);
                                $data->fieldClean($fn->f[$data->fnFields['fnname']]);
                                $name = $fn->f[$data->fnFields['fnname']] . "(". $fn->f[$data->fnFields['fnarguments']] .")";
                                break;
@@ -39,9 +39,9 @@
 
                if ($confirm) {
                        // Get users from the database
-                       $users = &$localData->getUsers();
+                       $users = &$data->getUsers();
                        // Get groups from the database
-                       $groups = &$localData->getGroups();
+                       $groups = &$data->getGroups();
 
                        echo "<h2>{$lang['strprivileges']}: ", $misc->printVal($name), ": {$lang['stralterprivs']}</h2>\n";
                        $misc->printMsg($msg);
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->setPrivileges(isset($_REQUEST['grant']) ? 'GRANT' : 'REVOKE', $_REQUEST['type'], $_REQUEST['object'],
+                       $status = $data->setPrivileges(isset($_REQUEST['grant']) ? 'GRANT' : 'REVOKE', $_REQUEST['type'], $_REQUEST['object'],
                                isset($_REQUEST['public']), $_REQUEST['username'], $_REQUEST['groupname'], array_keys($_REQUEST['privilege']),
                                isset($_REQUEST['grantoption']), isset($_REQUEST['cascade']));
                        if ($status == 0)
         * Show permissions on a database, namespace, relation, language or function
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc, $database;
+               global $data, $misc, $database;
                global $PHP_SELF, $lang;
 
                switch ($_REQUEST['type']) {
                $misc->printMsg($msg);
 
                // Get the privileges on the object, given its type
-               $privileges = $localData->getPrivileges($_REQUEST['object'], $_REQUEST['type']);
+               $privileges = $data->getPrivileges($_REQUEST['object'], $_REQUEST['type']);
 
                if (sizeof($privileges) > 0) {
                        echo "<table>\n";
index f6830e85adeec3c79e03ed33de06b03c5cadef4a..7f0e8bca13ead7245952057e723f3311071f770d 100644 (file)
--- a/rules.php
+++ b/rules.php
@@ -3,7 +3,7 @@
        /**
         * List rules on a table
         *
-        * $Id: rules.php,v 1.15 2003/10/26 10:59:16 chriskl Exp $
+        * $Id: rules.php,v 1.16 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -16,7 +16,7 @@
         * Confirm and then actually create a rule
         */
        function createRule($confirm, $msg = '') {
-               global $PHP_SELF, $data, $localData, $misc;
+               global $PHP_SELF, $data, $data, $misc;
                global $lang;
 
                if (!isset($_POST['name'])) $_POST['name'] = '';
@@ -68,7 +68,7 @@
                        if (trim($_POST['name']) == '')
                                createRule(true, $lang['strruleneedsname']);
                        else {
-                               $status = $localData->createRule($_POST['name'],
+                               $status = $data->createRule($_POST['name'],
                                        $_POST['event'], $_POST['table'], $_POST['where'],
                                        isset($_POST['instead']), $_POST['type'], $_POST['raction']);
                                if ($status == 0)
@@ -83,7 +83,7 @@
         * Show confirmation of drop and perform actual drop
         */
        function doDrop($confirm) {
-               global $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                if ($confirm) {
                        echo "<input type=\"hidden\" name=\"rule\" value=\"", htmlspecialchars($_REQUEST['rule']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" /> <input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\" />\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropRule($_POST['rule'], $_POST['table'], isset($_POST['cascade']));
+                       $status = $data->dropRule($_POST['rule'], $_POST['table'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strruledropped']);
                        else
         * List all the rules on the table
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF;
                global $lang;
 
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strrules']}</h2>\n";
                $misc->printMsg($msg);
 
-               $rules = &$localData->getRules($_REQUEST['table']);
+               $rules = &$data->getRules($_REQUEST['table']);
                
                if ($rules->recordCount() > 0) {
                        echo "<table>\n";
index 77a4ebba950d8e81f16ee8b5006dbe5afa3552b3..dfb5f433398f8107369c2fd4b25c94da98da1034 100755 (executable)
@@ -3,10 +3,11 @@
        /**
         * Display properties of a schema
         *
-        * $Id: schema.php,v 1.9 2003/10/27 05:43:18 chriskl Exp $
+        * $Id: schema.php,v 1.10 2003/12/10 16:03:29 chriskl Exp $
         */
 
-       // Include application functions
+       // Include application functions (no db conn)
+       $_no_db_connection = true;
        include_once('libraries/lib.inc.php');
 
        $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
index 92ff97fb0be603e138582aad348b0a2cb09f9d4d..c2297991d85134fed0718cae29f877295245c86c 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage sequences in a database
         *
-        * $Id: sequences.php,v 1.14 2003/09/08 03:00:12 chriskl Exp $
+        * $Id: sequences.php,v 1.15 2003/12/10 16:03:29 chriskl Exp $
         */
        
        // Include application functions
         * Display list of all sequences in the database/schema
         */     
        function doDefault($msg = '')   {
-               global $data, $localData, $misc; 
+               global $data, $misc; 
                global $PHP_SELF, $lang;
                
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strsequences']}</h2>\n";
                $misc->printMsg($msg);
                
                // Get all sequences
-               $sequences = &$localData->getSequences();
+               $sequences = &$data->getSequences();
                
                if (is_object($sequences) && $sequences->recordCount() > 0) {
                        echo "<table>\n";
         * Display the properties of a sequence
         */      
        function doProperties($msg = '') {
-               global $data, $localData, $misc, $PHP_SELF;
+               global $data, $misc, $PHP_SELF;
                global $lang;
                
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strsequences']} : ", $misc->printVal($_REQUEST['sequence']), ": {$lang['strproperties']}</h2>\n";
                $misc->printMsg($msg);
                
                // Fetch the sequence information
-               $sequence = &$localData->getSequence($_REQUEST['sequence']);            
+               $sequence = &$data->getSequence($_REQUEST['sequence']);         
                
                if (is_object($sequence) && $sequence->recordCount() > 0) {                     
                        echo "<table border=\"0\">";
         * Drop a sequence
         */             
        function doDrop($confirm, $msg = '') {
-               global $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
                
                if ($confirm) { 
                        echo "<input type=\"hidden\" name=\"sequence\" value=\"", htmlspecialchars($_REQUEST['sequence']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropSequence($_POST['sequence'], isset($_POST['cascade']));
+                       $status = $data->dropSequence($_POST['sequence'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strsequencedropped']);
                        else
         * Displays a screen where they can enter a new sequence
         */
        function doCreateSequence($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
                
                if (!isset($_POST['formSequenceName'])) $_POST['formSequenceName'] = '';
         * Actually creates the new sequence in the database
         */
        function doSaveCreateSequence() {
-               global $localData;
+               global $data;
                global $lang;
                
                // Check that they've given a name and at least one column
                if ($_POST['formSequenceName'] == '') doCreateSequence($lang['strsequenceneedsname']);
                else {
-                       $status = $localData->createSequence($_POST['formSequenceName'], $_POST['formIncrement'],
+                       $status = $data->createSequence($_POST['formSequenceName'], $_POST['formIncrement'],
                                                        $_POST['formMinValue'], $_POST['formMaxValue'], $_POST['formStartValue']);
                        if ($status == 0) {
                                doDefault($lang['strsequencecreated']);
         * Resets a sequence
         */
        function doReset() {
-               global $localData;
+               global $data;
                global $PHP_SELF, $lang;
                
-               $status = $localData->resetSequence($_REQUEST['sequence']);
+               $status = $data->resetSequence($_REQUEST['sequence']);
                if ($status == 0)
                        doProperties($lang['strsequencereset']);
                else    
diff --git a/sql.php b/sql.php
index 8c0236bb957c541ba8373df6687d976d94b95ef5..7f8c0f55f16577e283ffc5bf75e3d4ae3f5023ef 100644 (file)
--- a/sql.php
+++ b/sql.php
@@ -6,7 +6,7 @@
         * how many SQL statements have been strung together with semi-colons
         * @param $query The SQL query string to execute
         *
-        * $Id: sql.php,v 1.12 2003/11/15 11:09:32 chriskl Exp $
+        * $Id: sql.php,v 1.13 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -26,9 +26,9 @@
        }
        
        // Set fetch mode to NUM so that duplicate field names are properly returned
-       $localData->conn->setFetchMode(ADODB_FETCH_NUM);
+       $data->conn->setFetchMode(ADODB_FETCH_NUM);
        // Execute the query
-       $rs = $localData->conn->Execute($_POST['query']);
+       $rs = $data->conn->Execute($_POST['query']);
 
        // $rs will only be an object if there is no error
        if (is_object($rs)) {
@@ -58,8 +58,8 @@
                        echo "<p>", $rs->recordCount(), " {$lang['strrows']}</p>\n";
                }
                // Otherwise if any rows have been affected
-               elseif ($localData->conn->Affected_Rows() > 0) {
-                       echo "<p>", $localData->conn->Affected_Rows(), " {$lang['strrowsaff']}</p>\n";
+               elseif ($data->conn->Affected_Rows() > 0) {
+                       echo "<p>", $data->conn->Affected_Rows(), " {$lang['strrowsaff']}</p>\n";
                }
                // Else say success
                else echo "<p>{$lang['strsqlexecuted']}</p>\n";
index 98457d3304bcd763d8a0891119c79c39c05721ea..18af9871b46b7063d028ad4849b33fee80d32f98 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Alternative SQL editing window
         *
-        * $Id: sqledit.php,v 1.7 2003/10/31 02:36:49 chriskl Exp $
+        * $Id: sqledit.php,v 1.8 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -65,7 +65,7 @@
         * Allow execution of arbitrary SQL statements on a database
         */
        function doDefault() {
-               global $PHP_SELF, $data, $localData, $misc;
+               global $PHP_SELF, $data, $data, $misc;
                global $lang, $conf;
 
                if (!isset($_POST['query'])) $_POST['query'] = '';
index 839389157c9e76a3fb5094ae1f6f85faafef6897..8e48ce23d3e9f21abb44e9b7df71eb1929a9d6bc 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.39 2003/11/05 08:32:03 chriskl Exp $
+        * $Id: tables.php,v 1.40 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -16,7 +16,7 @@
         * Displays a screen where they can enter a new table
         */
        function doCreate($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                if (!isset($_REQUEST['stage'])) $_REQUEST['stage'] = 1;
@@ -65,7 +65,7 @@
                                        return;
                                }
 
-                               $types = &$localData->getTypes(true);
+                               $types = &$data->getTypes(true);
        
                                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: {$lang['strcreatetable']}</h2>\n";
                                $misc->printMsg($msg);
@@ -85,7 +85,7 @@
                                                htmlspecialchars($_REQUEST['field'][$i]), "\" /></td>";
                                        echo "<td><select name=\"type[{$i}]\">\n";
                                        // Output any "magic" types
-                                       foreach ($localData->extraTypes as $v) {
+                                       foreach ($data->extraTypes as $v) {
                                                echo "\t<option value=\"", htmlspecialchars($v), "\"",
                                                (isset($_REQUEST['type'][$i]) && $v == $_REQUEST['type'][$i]) ? ' selected="selected"' : '', ">",
                                                        $misc->printVal($v), "</option>\n";
                                                                
                                break;
                        case 3:
-                               global $localData, $lang, $_reload_browser;
+                               global $data, $lang, $_reload_browser;
 
                                if (!isset($_REQUEST['notnull'])) $_REQUEST['notnull'] = array();
 
                                        return;
                                }
                                
-                               $status = $localData->createTable($_REQUEST['name'], $_REQUEST['fields'], $_REQUEST['field'],
+                               $status = $data->createTable($_REQUEST['name'], $_REQUEST['fields'], $_REQUEST['field'],
                                                                $_REQUEST['type'], $_REQUEST['length'], $_REQUEST['notnull'], $_REQUEST['default'],
                                                                isset($_REQUEST['withoutoids']));
                                if ($status == 0) {
         * Ask for select parameters and perform select
         */
        function doSelectRows($confirm, $msg = '') {
-               global $localData, $database, $misc;
+               global $database, $misc;
                global $lang;
                global $PHP_SELF;
 
                        echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: ", $misc->printVal($_REQUEST['table']), ": {$lang['strselect']}</h2>\n";
                        $misc->printMsg($msg);
 
-                       $attrs = &$localData->getTableAttributes($_REQUEST['table']);
+                       $attrs = &$data->getTableAttributes($_REQUEST['table']);
 
                        echo "<form action=\"$PHP_SELF\" method=\"get\" name=\"selectform\">\n";
                        if ($attrs->recordCount() > 0) {
 
                                $i = 0;
                                while (!$attrs->EOF) {
-                                       $attrs->f['attnotnull'] = $localData->phpBool($attrs->f['attnotnull']);
+                                       $attrs->f['attnotnull'] = $data->phpBool($attrs->f['attnotnull']);
                                        // Set up default value if there isn't one already
                                        if (!isset($_REQUEST['values'][$attrs->f['attname']]))
                                                $_REQUEST['values'][$attrs->f['attname']] = null;
                                        echo "<input type=\"checkbox\" name=\"show[", htmlspecialchars($attrs->f['attname']), "]\"",
                                                isset($_REQUEST['show'][$attrs->f['attname']]) ? ' checked="checked"' : '', " /></td>";
                                        echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($attrs->f['attname']), "</td>";
-                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($localData->formatType($attrs->f['type'], $attrs->f['atttypmod'])), "</td>";
+                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod'])), "</td>";
                                        echo "<td class=\"data{$id}\" nowrap=\"nowrap\">";
                                        echo "<select name=\"ops[{$attrs->f['attname']}]\">\n";
-                                       foreach (array_keys($localData->selectOps) as $v) {
+                                       foreach (array_keys($data->selectOps) as $v) {
                                                echo "<option value=\"", htmlspecialchars($v), "\"", ($v == $_REQUEST['ops'][$attrs->f['attname']]) ? ' selected="selected"' : '', 
                                                ">", htmlspecialchars($v), "</option>\n";
                                        }
                                        echo "</select>\n";
-                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $localData->printField("values[{$attrs->f['attname']}]",
+                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $data->printField("values[{$attrs->f['attname']}]",
                                                $_REQUEST['values'][$attrs->f['attname']], $attrs->f['type']), "</td>";
                                        echo "</tr>\n";
                                        $i++;
                        
                        // Verify that they haven't supplied a value for unary operators
                        foreach ($_GET['ops'] as $k => $v) {
-                               if ($localData->selectOps[$v] == 'p' && $_GET['values'][$k] != '') {
+                               if ($data->selectOps[$v] == 'p' && $_GET['values'][$k] != '') {
                                        doSelectRows(true, $lang['strselectunary']);
                                        return;
                                }
                                doSelectRows(true, $lang['strselectneedscol']);                 
                        else {
                                // Generate query SQL
-                               $query = $localData->getSelectSQL($_REQUEST['table'], array_keys($_GET['show']),
+                               $query = $data->getSelectSQL($_REQUEST['table'], array_keys($_GET['show']),
                                        $_GET['values'], $_GET['ops']);
                                $_REQUEST['query'] = $query;
                                $_REQUEST['return_url'] = "tables.php?action=confselectrows&{$misc->href}&table={$_REQUEST['table']}";
         * Ask for insert parameters and then actually insert row
         */
        function doInsertRow($confirm, $msg = '') {
-               global $localData, $database, $misc;
+               global $database, $misc;
                global $lang;
                global $PHP_SELF;
 
                        echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: ", $misc->printVal($_REQUEST['table']), ": {$lang['strinsertrow']}</h2>\n";
                        $misc->printMsg($msg);
 
-                       $attrs = &$localData->getTableAttributes($_REQUEST['table']);
+                       $attrs = &$data->getTableAttributes($_REQUEST['table']);
 
                        echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
                        if ($attrs->recordCount() > 0) {
                                
                                $i = 0;
                                while (!$attrs->EOF) {
-                                       $attrs->f['attnotnull'] = $localData->phpBool($attrs->f['attnotnull']);
+                                       $attrs->f['attnotnull'] = $data->phpBool($attrs->f['attnotnull']);
                                        // Set up default value if there isn't one already
                                        if (!isset($_REQUEST['values'][$attrs->f['attname']]))
                                                $_REQUEST['values'][$attrs->f['attname']] = $attrs->f['adsrc'];
                                        echo "<tr>\n";
                                        echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($attrs->f['attname']), "</td>";
                                        echo "<td class=\"data{$id}\" nowrap=\"nowrap\">\n";
-                                       echo $misc->printVal($localData->formatType($attrs->f['type'], $attrs->f['atttypmod']));
+                                       echo $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod']));
                                        echo "<input type=\"hidden\" name=\"types[", htmlspecialchars($attrs->f['attname']), "]\" value=\"", 
                                                htmlspecialchars($attrs->f['type']), "\" /></td>";
                                        echo "<td class=\"data{$id}\" nowrap=\"nowrap\">\n";
                                                        isset($_REQUEST['nulls'][$attrs->f['attname']]) ? ' checked="checked"' : '', " /></td>";
                                        else
                                                echo "&nbsp;</td>";
-                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $localData->printField("values[{$attrs->f['attname']}]",
+                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $data->printField("values[{$attrs->f['attname']}]",
                                                $_REQUEST['values'][$attrs->f['attname']], $attrs->f['type']), "</td>";
                                        echo "</tr>\n";
                                        $i++;
                        if (!isset($_POST['values'])) $_POST['values'] = array();
                        if (!isset($_POST['nulls'])) $_POST['nulls'] = array();
 
-                       $status = $localData->insertRow($_POST['table'], $_POST['values'], 
+                       $status = $data->insertRow($_POST['table'], $_POST['values'], 
                                                                                                $_POST['nulls'], $_POST['format'], $_POST['types']);
                        if ($status == 0) {
                                if (isset($_POST['save']))
         * Show confirmation of empty and perform actual empty
         */
        function doEmpty($confirm) {
-               global $localData, $database, $misc;
+               global $database, $misc;
                global $lang;
                global $PHP_SELF;
 
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->emptyTable($_POST['table']);
+                       $status = $data->emptyTable($_POST['table']);
                        if ($status == 0)
                                doDefault($lang['strtableemptied']);
                        else
         * Show confirmation of drop and perform actual drop
         */
        function doDrop($confirm) {
-               global $localData, $database, $misc;
+               global $database, $misc;
                global $lang, $_reload_browser;
                global $PHP_SELF;
 
                        echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropTable($_POST['table'], isset($_POST['cascade']));
+                       $status = $data->dropTable($_POST['table'], isset($_POST['cascade']));
                        if ($status == 0) {
                                $_reload_browser = true;
                                doDefault($lang['strtabledropped']);
         * Show default list of tables in the database
         */
        function doDefault($msg = '') {
-               global $data, $misc, $localData;
+               global $data, $misc, $data;
                global $PHP_SELF, $lang;
                
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}</h2>\n";
                        
-               $tables = &$localData->getTables();
+               $tables = &$data->getTables();
                
                if ($tables->recordCount() > 0) {
                        echo "<table>\n";
index 9b1e3060416a0d119e1efa8553e16e58a6d82155..8eb132958f23e3f422c61c914738c964ab14c325 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tblproperties.php,v 1.30 2003/11/05 08:32:03 chriskl Exp $
+        * $Id: tblproperties.php,v 1.31 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
         * Function to save after altering a table
         */
        function doSaveAlter() {
-               global $localData, $lang, $_reload_browser;
+               global $data, $lang, $_reload_browser;
 
                // For databases that don't allow owner change
                if (!isset($_POST['owner'])) $_POST['owner'] = '';
                
-               $status = $localData->alterTable($_POST['table'], $_POST['name'], $_POST['owner'], $_POST['comment']);
+               $status = $data->alterTable($_POST['table'], $_POST['name'], $_POST['owner'], $_POST['comment']);
                if ($status == 0) {
                        // Jump them to the new table name
                        $_REQUEST['table'] = $_POST['name'];
         * Function to allow altering of a table
         */
        function doAlter($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
                
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['stralter']}</h2>\n";
                $misc->printMsg($msg);
 
                // Fetch table info             
-               $table = &$localData->getTable($_REQUEST['table']);
+               $table = &$data->getTable($_REQUEST['table']);
                // Fetch all users
                $users = &$data->getUsers();
                
        }
        
        function doExport($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                // Determine whether or not the table has an object ID
-               $hasID = $localData->hasObjectID($_REQUEST['table']);
+               $hasID = $data->hasObjectID($_REQUEST['table']);
                
                $misc->printTableNav();
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strexport']}</h2>\n";
         * Displays a screen where they can add a column
         */
        function doAddColumn($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                if (!isset($_REQUEST['stage'])) $_REQUEST['stage'] = 1;
                                if (!isset($_POST['length'])) $_POST['length'] = '';
 
                                // Fetch all available types
-                               $types = &$localData->getTypes(true);
+                               $types = &$data->getTypes(true);
 
                                echo "<h2>", $misc->printVal($_REQUEST['database']), ": ",
                                        $misc->printVal($_REQUEST['table']), ": {$lang['straddcolumn']}</h2>\n";
 
                                break;
                        case 2:
-                               global $localData, $lang;
+                               global $data, $lang;
 
                                // Check inputs
                                if (trim($_POST['field']) == '') {
                                        return;
                                }
                                
-                               $status = $localData->addColumn($_POST['table'], $_POST['field'],
+                               $status = $data->addColumn($_POST['table'], $_POST['field'],
                                                                $_POST['type'], $_POST['length']);
                                if ($status == 0)
                                        doDefault($lang['strcolumnadded']);
         * Displays a screen where they can alter a column
         */
        function doProperties($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                if (!isset($_REQUEST['stage'])) $_REQUEST['stage'] = 1;
                                echo "<table>\n<tr>";
                                echo "<tr><th class=\"data\">{$lang['strfield']}</th><th class=\"data\">{$lang['strtype']}</th><th class=\"data\">{$lang['strnotnull']}</th><th class=\"data\">{$lang['strdefault']}</th></tr>";
 
-                               $column = &$localData->getTableAttributes($_REQUEST['table'], $_REQUEST['column']);
-                               $column->f['attnotnull'] = $localData->phpBool($column->f['attnotnull']);
+                               $column = &$data->getTableAttributes($_REQUEST['table'], $_REQUEST['column']);
+                               $column->f['attnotnull'] = $data->phpBool($column->f['attnotnull']);
 
                                if (!isset($_REQUEST['default'])) {
                                        $_REQUEST['field'] = $column->f['attname'];
 
                                echo "<tr><td><input name=\"field\" size=\"32\" value=\"",
                                        htmlspecialchars($_REQUEST['field']), "\" /></td>";
-                               echo "<td>", $misc->printVal($localData->formatType($column->f['type'], $column->f['atttypmod'])), "</td>";
+                               echo "<td>", $misc->printVal($data->formatType($column->f['type'], $column->f['atttypmod'])), "</td>";
                                echo "<td><input type=\"checkbox\" name=\"notnull\"", (isset($_REQUEST['notnull'])) ? ' checked="checked"' : '', " /></td>\n";
                                echo "<td><input name=\"default\" size=\"20\" value=\"", 
                                        htmlspecialchars($_REQUEST['default']), "\" /></td>";
                                                                
                                break;
                        case 2:
-                               global $localData, $lang;
+                               global $data, $lang;
 
                                // Check inputs
                                if (trim($_REQUEST['field']) == '') {
                                        return;
                                }
                                
-                               $status = $localData->alterColumn($_REQUEST['table'], $_REQUEST['column'], $_REQUEST['field'], 
+                               $status = $data->alterColumn($_REQUEST['table'], $_REQUEST['column'], $_REQUEST['field'], 
                                                                isset($_REQUEST['notnull']), $_REQUEST['default'], $_REQUEST['olddefault']);
                                if ($status == 0)
                                        doDefault($lang['strcolumnaltered']);
         * Show confirmation of drop column and perform actual drop
         */
        function doDrop($confirm) {
-               global $localData, $database, $misc;
+               global $data, $database, $misc;
                global $PHP_SELF, $lang;
 
                if ($confirm) {
                        echo "<input type=\"hidden\" name=\"column\" value=\"", htmlspecialchars($_REQUEST['column']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\"> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropColumn($_POST['table'], $_POST['column'], isset($_POST['cascade']));
+                       $status = $data->dropColumn($_POST['table'], $_POST['column'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strcolumndropped']);
                        else
         * Show default list of columns in the table
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                $misc->printTableNav();
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), "</h2>\n";
 
                // Get table
-               $tdata = &$localData->getTable($_REQUEST['table']);
+               $tdata = &$data->getTable($_REQUEST['table']);
                // Get columns
-               $attrs = &$localData->getTableAttributes($_REQUEST['table']);           
+               $attrs = &$data->getTableAttributes($_REQUEST['table']);                
                $misc->printMsg($msg);
 
                // Show comment if any
 
                $i = 0;
                while (!$attrs->EOF) {
-                       $attrs->f['attnotnull'] = $localData->phpBool($attrs->f['attnotnull']);
+                       $attrs->f['attnotnull'] = $data->phpBool($attrs->f['attnotnull']);
                        $id = (($i % 2) == 0 ? '1' : '2');
                        echo "<tr>\n\t<td class=\"data{$id}\">", $misc->printVal($attrs->f['attname']), "</td>\n";
-                       echo "\t<td class=\"data{$id}\">", $misc->printVal($localData->formatType($attrs->f['type'], $attrs->f['atttypmod'])), "</td>\n";
+                       echo "\t<td class=\"data{$id}\">", $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod'])), "</td>\n";
                        echo "\t<td class=\"data{$id}\">", ($attrs->f['attnotnull'] ? 'NOT NULL' : ''), "</td>\n";
                        echo "\t<td class=\"data{$id}\">", $misc->printVal($attrs->f['adsrc']), "</td>\n";
                        echo "\t<td class=\"opbutton{$id}\"><a href=\"{$PHP_SELF}?{$misc->href}&table=", urlencode($_REQUEST['table']),
index 3a781614c313dd7b57ee316dd8659796a1826be5..6df2f4815822dcd8e4a7fddd9abd64b9e068e8f0 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List triggers on a table
         *
-        * $Id: triggers.php,v 1.16 2003/07/30 07:02:29 chriskl Exp $
+        * $Id: triggers.php,v 1.17 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -17,9 +17,9 @@
         * Function to save after altering a trigger
         */
        function doSaveAlter() {
-               global $localData, $lang;
+               global $data, $lang;
                
-               $status = $localData->alterTrigger($_POST['table'], $_POST['trigger'], $_POST['name']);
+               $status = $data->alterTrigger($_POST['table'], $_POST['trigger'], $_POST['name']);
                if ($status == 0)
                        doDefault($lang['strtriggeraltered']);
                else
         * Function to allow altering of a trigger
         */
        function doAlter($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
                
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtriggers']}: ", $misc->printVal($_REQUEST['trigger']), ": {$lang['stralter']}</h2>\n";
                $misc->printMsg($msg);
                
-               $triggerdata = &$localData->getTrigger($_REQUEST['table'], $_REQUEST['trigger']);
+               $triggerdata = &$data->getTrigger($_REQUEST['table'], $_REQUEST['trigger']);
                
                if ($triggerdata->recordCount() > 0) {
                        
@@ -64,7 +64,7 @@
         * Show confirmation of drop and perform actual drop
         */
        function doDrop($confirm) {
-               global $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                if ($confirm) {
@@ -80,7 +80,7 @@
                        echo "<input type=\"hidden\" name=\"trigger\" value=\"", htmlspecialchars($_REQUEST['trigger']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />\n";
@@ -88,7 +88,7 @@
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropTrigger($_POST['trigger'], $_POST['table'], isset($_POST['cascade']));
+                       $status = $data->dropTrigger($_POST['trigger'], $_POST['table'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strtriggerdropped']);
                        else
         * Let them create s.th.
         */
        function doCreate($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
                
                echo "<h2>{$lang['strcreatetrigger']}</h2>";
                $misc->printMsg($msg);
                
                // Get all the functions that can be used in triggers
-               $funcs = &$localData->getTriggerFunctions();
+               $funcs = &$data->getTriggerFunctions();
                if ($funcs->recordCount() == 0) {
                        doDefault($lang['strnofunctions']);
                        return;
 
                /* Populate times */
                $sel1 = new XHTML_Select('formExecTime');
-               $sel1->set_data($localData->triggerExecTimes);
+               $sel1->set_data($data->triggerExecTimes);
 
                /* Populate events */
                $sel2 = new XHTML_Select('formEvent');
-               $sel2->set_data($localData->triggerEvents);
+               $sel2->set_data($data->triggerEvents);
                
                echo "<form action=\"$PHP_SELF\" method=\"POST\">\n";
                echo "<table>\n";
         * Actually creates the new trigger in the database
         */
        function doSaveCreate() {
-               global $localData;
+               global $data;
                global $PHP_SELF, $lang;                
        
                // Check that they've given a name and a definition
                elseif ($_POST['formEvent'] == '') 
                        doCreate();
                else {           
-                       $status = &$localData->createTrigger($_POST['formTriggerName'], $_POST['table'],
+                       $status = &$data->createTrigger($_POST['formTriggerName'], $_POST['table'],
                                        $_POST['formFunction'], $_POST['formExecTime'], $_POST['formEvent'],
                                        $_POST['formTriggerArgs']);
                        if ($status == 0)
         * List all the triggers on the table
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc, $database;
+               global $data, $misc, $database;
                global $PHP_SELF;
                global $lang;
 
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strtriggers']}</h2>\n";
                $misc->printMsg($msg);
 
-               $triggers = &$localData->getTriggers($_REQUEST['table']);
+               $triggers = &$data->getTriggers($_REQUEST['table']);
 
                if ($triggers->recordCount() > 0) {
                        echo "<table>\n";
                                if ($triggers->f[$data->tgFields['tgdef']] !== null)
                                        echo $misc->printVal($triggers->f[$data->tgFields['tgdef']]);
                                else 
-                                       echo $misc->printVal($localData->getTriggerDef($triggers->f));
+                                       echo $misc->printVal($data->getTriggerDef($triggers->f));
                                echo "</td>\n";                         
                                if ($data->hasAlterTrigger()) {
                                        echo "<td class=\"opbutton{$id}\"><a href=\"$PHP_SELF?action=confirm_alter&{$misc->href}&trigger=", urlencode($triggers->f[$data->tgFields['tgname']]),
index b97a9b7af37b5fcb40dabcaea9d7d4382cba7a89..3715dd9e9b2a1703c9dbc0c00fe4d4e51936d490 100644 (file)
--- a/types.php
+++ b/types.php
@@ -3,7 +3,7 @@
        /**
         * Manage types in a database
         *
-        * $Id: types.php,v 1.11 2003/09/09 06:23:12 chriskl Exp $
+        * $Id: types.php,v 1.12 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
         * Show read only properties for a type
         */
        function doProperties($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtypes']}: ", $misc->printVal($_REQUEST['type']), ": {$lang['strproperties']}</h2>\n";
                $misc->printMsg($msg);
                
-               $typedata = &$localData->getType($_REQUEST['type']);
+               $typedata = &$data->getType($_REQUEST['type']);
                
                if ($typedata->recordCount() > 0) {
                        $byval = $data->phpBool($typedata->f[$data->typFields['typbyval']]);
@@ -51,7 +51,7 @@
         * Show confirmation of drop and perform actual drop
         */
        function doDrop($confirm) {
-               global $localData, $database, $misc;
+               global $database, $misc;
                global $PHP_SELF, $lang;
 
                if ($confirm) { 
@@ -64,7 +64,7 @@
                        echo "<input type=\"hidden\" name=\"type\" value=\"", htmlspecialchars($_REQUEST['type']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
@@ -72,7 +72,7 @@
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropType($_POST['type'], isset($_POST['cascade']));
+                       $status = $data->dropType($_POST['type'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strtypedropped']);
                        else
@@ -85,7 +85,7 @@
         * Displays a screen where they can enter a new type
         */
        function doCreate($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                if (!isset($_POST['typname'])) $_POST['typname'] = '';
@@ -99,8 +99,8 @@
                if (!isset($_POST['typstorage'])) $_POST['typstorage'] = $data->typStorageDef;
 
                // Retrieve all functions and types in the database
-               $funcs = &$localData->getFunctions(true);
-               $types = &$localData->getTypes();
+               $funcs = &$data->getFunctions(true);
+               $types = &$data->getTypes();
 
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtypes']}: {$lang['strcreatetype']}</h2>\n";
                $misc->printMsg($msg);
         * Actually creates the new type in the database
         */
        function doSaveCreate() {
-               global $localData;
+               global $data;
                global $lang;
 
                // Check that they've given a name and a length.
                if ($_POST['typname'] == '') doCreate($lang['strtypeneedsname']);
                elseif ($_POST['typlen'] == '') doCreate($lang['strtypeneedslen']);
                else {           
-                       $status = $localData->createType(
+                       $status = $data->createType(
                                $_POST['typname'],
                                $_POST['typin'],
                                $_POST['typout'],
         * Show default list of types in the database
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc, $database;
+               global $data, $misc, $database;
                global $PHP_SELF, $lang;
 
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtypes']}</h2>\n";
                $misc->printMsg($msg);
                
-               $types = &$localData->getTypes();
+               $types = &$data->getTypes();
 
                if ($types->recordCount() > 0) {
                        echo "<table>\n";
index 6f11bb9aeeb176b15e2905c2d15457d63b614ba7..e4cd592de111bb2e150cd607265c3c6a4ece8f8a 100644 (file)
--- a/views.php
+++ b/views.php
@@ -3,7 +3,7 @@
        /**
         * Manage views in a database
         *
-        * $Id: views.php,v 1.24 2003/11/05 08:32:03 chriskl Exp $
+        * $Id: views.php,v 1.25 2003/12/10 16:03:29 chriskl Exp $
         */
 
        // Include application functions
@@ -17,7 +17,7 @@
         * Ask for select parameters and perform select
         */
        function doSelectRows($confirm, $msg = '') {
-               global $localData, $database, $misc;
+               global $database, $misc;
                global $lang;
                global $PHP_SELF;
 
@@ -25,7 +25,7 @@
                        echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strviews']}: ", $misc->printVal($_REQUEST['view']), ": {$lang['strselect']}</h2>\n";
                        $misc->printMsg($msg);
 
-                       $attrs = &$localData->getTableAttributes($_REQUEST['view']);
+                       $attrs = &$data->getTableAttributes($_REQUEST['view']);
 
                        echo "<form action=\"$PHP_SELF\" method=\"get\" name=\"selectform\">\n";
                        if ($attrs->recordCount() > 0) {
@@ -50,7 +50,7 @@
 
                                $i = 0;
                                while (!$attrs->EOF) {
-                                       $attrs->f['attnotnull'] = $localData->phpBool($attrs->f['attnotnull']);
+                                       $attrs->f['attnotnull'] = $data->phpBool($attrs->f['attnotnull']);
                                        // Set up default value if there isn't one already
                                        if (!isset($_REQUEST['values'][$attrs->f['attname']]))
                                                $_REQUEST['values'][$attrs->f['attname']] = null;
                                        echo "<input type=\"checkbox\" name=\"show[", htmlspecialchars($attrs->f['attname']), "]\"",
                                                isset($_REQUEST['show'][$attrs->f['attname']]) ? ' checked="checked"' : '', " /></td>";
                                        echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($attrs->f['attname']), "</td>";
-                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($localData->formatType($attrs->f['type'], $attrs->f['atttypmod'])), "</td>";
+                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod'])), "</td>";
                                        echo "<td class=\"data{$id}\" nowrap=\"nowrap\">";
                                        echo "<select name=\"ops[{$attrs->f['attname']}]\">\n";
-                                       foreach (array_keys($localData->selectOps) as $v) {
+                                       foreach (array_keys($data->selectOps) as $v) {
                                                echo "<option value=\"", htmlspecialchars($v), "\"", ($v == $_REQUEST['ops'][$attrs->f['attname']]) ? ' selected="selected"' : '', 
                                                ">", htmlspecialchars($v), "</option>\n";
                                        }
                                        echo "</select>\n";
-                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $localData->printField("values[{$attrs->f['attname']}]",
+                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $data->printField("values[{$attrs->f['attname']}]",
                                                $_REQUEST['values'][$attrs->f['attname']], $attrs->f['type']), "</td>";
                                        echo "</tr>\n";
                                        $i++;
@@ -97,7 +97,7 @@
                        
                        // Verify that they haven't supplied a value for unary operators
                        foreach ($_GET['ops'] as $k => $v) {
-                               if ($localData->selectOps[$v] == 'p' && $_GET['values'][$k] != '') {
+                               if ($data->selectOps[$v] == 'p' && $_GET['values'][$k] != '') {
                                        doSelectRows(true, $lang['strselectunary']);
                                        return;
                                }
                                doSelectRows(true, $lang['strselectneedscol']);                 
                        else {
                                // Generate query SQL
-                               $query = $localData->getSelectSQL($_REQUEST['view'], array_keys($_GET['show']),
+                               $query = $data->getSelectSQL($_REQUEST['view'], array_keys($_GET['show']),
                                        $_GET['values'], $_GET['ops']);
                                $_REQUEST['query'] = $query;
                                $_REQUEST['return_url'] = "views.php?action=confselectrows&{$misc->href}&view={$_REQUEST['view']}";
         * Function to save after editing a view
         */
        function doSaveEdit() {
-               global $localData, $lang;
+               global $data, $lang;
                
-               $status = $localData->setView($_POST['view'], $_POST['formDefinition']);
+               $status = $data->setView($_POST['view'], $_POST['formDefinition']);
                if ($status == 0)
                        doProperties($lang['strviewupdated']);
                else
         * Function to allow editing of a view
         */
        function doEdit($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
                
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strviews']}: ", $misc->printVal($_REQUEST['view']), ": {$lang['stredit']}</h2>\n";
                $misc->printMsg($msg);
                
-               $viewdata = &$localData->getView($_REQUEST['view']);
+               $viewdata = &$data->getView($_REQUEST['view']);
                
                if ($viewdata->recordCount() > 0) {
                        
         * Show read only properties for a view
         */
        function doProperties($msg = '') {
-               global $data, $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
        
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strviews']}: ", $misc->printVal($_REQUEST['view']), ": {$lang['strproperties']}</h2>\n";
                $misc->printMsg($msg);
                
-               $viewdata = &$localData->getView($_REQUEST['view']);
+               $viewdata = &$data->getView($_REQUEST['view']);
                
                if ($viewdata->recordCount() > 0) {
                        echo "<table width=\"100%\">\n";
         * Show confirmation of drop and perform actual drop
         */
        function doDrop($confirm) {
-               global $localData, $misc;
+               global $data, $misc;
                global $PHP_SELF, $lang;
 
                if ($confirm) { 
                        echo "<input type=\"hidden\" name=\"view\" value=\"", htmlspecialchars($_REQUEST['view']), "\" />\n";
                        echo $misc->form;
                        // Show cascade drop option if supportd
-                       if ($localData->hasDropBehavior()) {
+                       if ($data->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
                        echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $localData->dropView($_POST['view'], isset($_POST['cascade']));
+                       $status = $data->dropView($_POST['view'], isset($_POST['cascade']));
                        if ($status == 0)
                                doDefault($lang['strviewdropped']);
                        else
         * Displays a screen where they can enter a new view
         */
        function doCreate($msg = '') {
-               global $data, $localData, $misc, $conf;
+               global $data, $misc, $conf;
                global $PHP_SELF, $lang;
                
                if (!isset($_REQUEST['formView'])) $_REQUEST['formView'] = '';
         * Actually creates the new view in the database
         */
        function doSaveCreate() {
-               global $localData, $lang;
+               global $data, $lang;
                
                // Check that they've given a name and a definition
                if ($_POST['formView'] == '') doCreate($lang['strviewneedsname']);
                elseif ($_POST['formDefinition'] == '') doCreate($lang['strviewneedsdef']);
                else {           
-                       $status = $localData->createView($_POST['formView'], $_POST['formDefinition'], false);
+                       $status = $data->createView($_POST['formView'], $_POST['formDefinition'], false);
                        if ($status == 0)
                                doDefault($lang['strviewcreated']);
                        else
         * Show default list of views in the database
         */
        function doDefault($msg = '') {
-               global $data, $localData, $misc, $conf;
+               global $data, $misc, $conf;
                global $PHP_SELF, $lang;
                
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strviews']}</h2>\n";
                //$misc->printHelp("/tutorial-views.html");
                $misc->printMsg($msg);
                
-               $views = &$localData->getViews();
+               $views = &$data->getViews();
                
                if ($views->recordCount() > 0) {
                        echo "<table>\n";