tablespaces on databases. remove uFields in tablespaces
authorchriskl <chriskl>
Fri, 9 Jul 2004 01:50:43 +0000 (01:50 +0000)
committerchriskl <chriskl>
Fri, 9 Jul 2004 01:50:43 +0000 (01:50 +0000)
all_db.php
classes/database/Postgres.php
database.php
tablespaces.php

index 2b9590b61871a011271f56dd8b0c88e841e68aa3..df3699dd26a0cf61e30615cd189aed74c5685d50 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage databases within a server
         *
-        * $Id: all_db.php,v 1.25 2004/07/08 17:57:32 xzilla Exp $
+        * $Id: all_db.php,v 1.26 2004/07/09 01:50:43 chriskl Exp $
         */
 
        // Include application functions
                        else
                                $_POST['formEncoding'] = '';
                }
+               if (!isset($_POST['formSpc'])) $_POST['formSpc'] = '';
                
+               // Fetch all tablespaces from the database
+               if ($data->hasTablespaces()) $tablespaces = &$data->getTablespaces();
+
                $misc->printTitle(array($lang['strdatabases'], $lang['strcreatedatabase']), 'create_database');
                $misc->printMsg($msg);
                
                }
                echo "\t\t\t</select>\n";
                echo "\t\t</td>\n\t</tr>\n";
+               
+               // Tablespace (if there are any)
+               if ($data->hasTablespaces() && $tablespaces->recordCount() > 0) {
+                       echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strtablespace']}</th>\n";
+                       echo "\t\t<td class=\"data1\">\n\t\t\t<select name=\"formSpc\">\n";
+                       // Always offer the default (empty) option
+                       echo "\t\t\t\t<option value=\"\"",
+                               ($_POST['formSpc'] == '') ? ' selected="selected"' : '', "></option>\n";
+                       // Display all other tablespaces
+                       while (!$tablespaces->EOF) {
+                               $spcname = htmlspecialchars($tablespaces->f['spcname']);
+                               echo "\t\t\t\t<option value=\"{$spcname}\"",
+                                       ($spcname == $_POST['formSpc']) ? ' selected="selected"' : '', ">{$spcname}</option>\n";
+                               $tablespaces->moveNext();
+                       }
+                       echo "\t\t\t</select>\n\t\t</td>\n\t</tr>\n";
+               }
+               
                echo "</table>\n";
                echo "<p><input type=\"hidden\" name=\"action\" value=\"save_create\" />\n";
                echo "<input type=\"submit\" value=\"{$lang['strcreate']}\" />\n";
        function doSaveCreate() {
                global $data, $lang, $_reload_browser;
                
+               // Default tablespace to null if it isn't set
+               if (!isset($_POST['formSpc'])) $_POST['formSpc'] = null;
+
                // Check that they've given a name and a definition
                if ($_POST['formName'] == '') doCreate($lang['strdatabaseneedsname']);
                else {
-                       $status = $data->createDatabase($_POST['formName'], $_POST['formEncoding']);
+                       $status = $data->createDatabase($_POST['formName'], $_POST['formEncoding'], $_POST['formSpc']);
                        if ($status == 0) {
                                $_reload_browser = true;
                                doDefault($lang['strdatabasecreated']);
index ec13f09e337a9f3756e8a9ae322bf52f8f5089bf..8a4f0ed84f551ba20b4c82536f7d57724727c5e0 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.229 2004/07/08 17:57:31 xzilla Exp $
+ * $Id: Postgres.php,v 1.230 2004/07/09 01:50:43 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -952,17 +952,22 @@ class Postgres extends BaseDB {
         * Creates a database
         * @param $database The name of the database to create
         * @param $encoding Encoding of the database
+        * @param $tablespace (optional) The tablespace name
         * @return 0 success
         */
-       function createDatabase($database, $encoding) {
+       function createDatabase($database, $encoding, $tablespace = '') {
                $this->fieldClean($database);
                $this->clean($encoding);
+               $this->fieldClean($tablespace);
 
-               if ( $encoding == '' ) {
+               if ($encoding == '') {
                        $sql = "CREATE DATABASE \"{$database}\"";
                } else {
                        $sql = "CREATE DATABASE \"{$database}\" WITH ENCODING='{$encoding}'";
                }
+               
+               if ($tablespace != '' && $this->hasTablespaces()) $sql .= " TABLESPACE \"{$tablespace}\"";
+               
                return $this->execute($sql);
        }
 
index ab590706673acdaef85345b84c667ea9cc0fbc51..a3a08c5aaaff46b0b4e32347029e846f6a01df58 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.51 2004/07/08 03:23:01 chriskl Exp $
+        * $Id: database.php,v 1.52 2004/07/09 01:50:43 chriskl Exp $
         */
 
        // Include application functions
                                        ($spcname == $_POST['formSpc']) ? ' selected="selected"' : '', ">{$spcname}</option>\n";
                                $tablespaces->moveNext();
                        }
-                       echo "\t\t\t</select>\n\t\t</td>\n\t\n";
+                       echo "\t\t\t</select>\n\t\t</td>\n\t</tr>\n";
                }
                
                echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strcomment']}</th>\n";
index 82855da4b0f638a1021d4e08a6678380d4e3dd59..7ea1487f3ff63625ac5e34e6d464d9365f4ce4cd 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage tablespaces in a database cluster
         *
-        * $Id: tablespaces.php,v 1.1 2004/07/05 14:06:10 chriskl Exp $
+        * $Id: tablespaces.php,v 1.2 2004/07/09 01:50:43 chriskl Exp $
         */
 
        // Include application functions
@@ -25,7 +25,7 @@
 
                // Fetch tablespace info                
                $tablespace = &$data->getTablespace($_REQUEST['spcname']);
-               // Fetch all users
+               // Fetch all users              
                $users = &$data->getUsers();
                
                if ($tablespace->recordCount() > 0) {
@@ -42,7 +42,7 @@
                        echo "<tr><th class=\"data left required\">{$lang['strowner']}</th>\n";
                        echo "<td class=\"data1\"><select name=\"owner\">";
                        while (!$users->EOF) {
-                               $uname = $users->f[$data->uFields['uname']];
+                               $uname = $users->f['usename'];
                                echo "<option value=\"", htmlspecialchars($uname), "\"",
                                        ($uname == $_POST['owner']) ? ' selected="selected"' : '', ">", htmlspecialchars($uname), "</option>\n";
                                $users->moveNext();
                if (!isset($_POST['formSpcname'])) $_POST['formSpcname'] = '';
                if (!isset($_POST['formOwner'])) $_POST['formOwner'] = $_SESSION['webdbUsername'];
                if (!isset($_POST['formLoc'])) $_POST['formLoc'] = '';
-               
+
                // Fetch all users
                $users = &$data->getUsers();
                
                echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strowner']}</th>\n";
                echo "\t\t<td class=\"data1\"><select name=\"formOwner\">\n";
                while (!$users->EOF) {
-                       $uname = $users->f[$data->uFields['uname']];
+                       $uname = $users->f['usename'];
                        echo "\t\t\t<option value=\"", htmlspecialchars($uname), "\"",
                                ($uname == $_POST['formOwner']) ? ' selected="selected"' : '', ">", htmlspecialchars($uname), "</option>\n";
                        $users->moveNext();