/**
* 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']);
* 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???
* 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);
}
/**
* 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";
/**
* 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
// Fetch tablespace info
$tablespace = &$data->getTablespace($_REQUEST['spcname']);
- // Fetch all users
+ // Fetch all users
$users = &$data->getUsers();
if ($tablespace->recordCount() > 0) {
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();