* A class that implements the DB interface for Postgres\r
* Note: This class uses ADODB and returns RecordSets.\r
*\r
- * $Id: Postgres.php,v 1.22 2002/11/14 01:04:38 chriskl Exp $\r
+ * $Id: Postgres.php,v 1.23 2002/11/18 04:57:33 chriskl Exp $\r
*/\r
\r
// @@@ THOUGHT: What about inherits? ie. use of ONLY???\r
var $vwFields = array('vwname' => 'viewname', 'vwowner' => 'viewowner', 'vwdef' => 'definition');\r
var $uFields = array('uname' => 'usename', 'usuper' => 'usesuper', 'ucreatedb' => 'usecreatedb', 'uexpires' => 'valuntil');\r
var $sqFields = array('seqname' => 'relname', 'seqowner' => 'usename', 'lastvalue' => 'last_value', 'incrementby' => 'increment_by', 'maxvalue' => 'max_value', 'minvalue'=> 'min_value', 'cachevalue' => 'cache_value', 'logcount' => 'log_cnt', 'iscycled' => 'is_cycled', 'iscalled' => 'is_called' );\r
- var $ixFields = array('idxname' => 'relname', 'tabname' => 'tab_name', 'columnname' => 'column_name', 'uniquekey' => 'unique_key', 'primarykey' => 'primary_key');\r
+ var $ixFields = array('idxname' => 'relname', 'idxdef' => 'pg_get_indexdef', 'uniquekey' => 'indisunique', 'primarykey' => 'indisprimary');\r
\r
// Last oid assigned to a system object\r
var $_lastSystemOID = 18539;\r
}\r
\r
/**\r
- * grabs a list of indicies in the database\r
+ * Grabs a list of indicies in the database or table\r
+ * @param $table (optional) The name of a table to get the indicies for\r
*/\r
- function &getIndicies() {\r
- if (!$this->_showSystem)\r
+ function &getIndicies($table = '') {\r
+ $this->clean($table);\r
+\r
+ $sql = "SELECT c2.relname, i.indisprimary, i.indisunique, pg_catalog.pg_get_indexdef(i.indexrelid)\r
+ FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\r
+ WHERE c.oid = '16977' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\r
+ ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname";\r
+\r
+ \r
+ if ($table != '')\r
+ $where = "WHERE relname='{$table}' AND ";\r
+ elseif (!$this->_showSystem)\r
$where = "WHERE relname NOT LIKE 'pg_%' AND ";\r
else $where = '';\r
\r
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres72.php,v 1.15 2002/11/14 01:04:38 chriskl Exp $
+ * $Id: Postgres72.php,v 1.16 2002/11/18 04:57:33 chriskl Exp $
*/
return $this->selectSet($sql);
}
+ /**
+ * Grabs a list of indexes for a table
+ * @param $table The name of a table whose indexes to retrieve
+ * @return A recordset
+ */
+ function &getIndexes($table = '') {
+ $this->clean($table);
+ $sql = "SELECT c2.relname, i.indisprimary, i.indisunique, pg_get_indexdef(i.indexrelid)
+ FROM pg_class c, pg_class c2, pg_index i
+ WHERE c.relname = '{$table}' AND c.oid = i.indrelid AND i.indexrelid = c2.oid
+ ORDER BY c2.relname";
+
+ return $this->selectSet($sql);
+ }
}
* A class that implements the DB interface for Postgres\r
* Note: This class uses ADODB and returns RecordSets.\r
*\r
- * $Id: Postgres73.php,v 1.5 2002/09/15 07:29:08 chriskl Exp $\r
+ * $Id: Postgres73.php,v 1.6 2002/11/18 04:57:33 chriskl Exp $\r
*/\r
\r
// @@@ THOUGHT: What about inherits? ie. use of ONLY???\r
return $this->selectSet($sql);\r
\r
}\r
+\r
+ /**\r
+ * Grabs a list of indexes for a table\r
+ * @param $table The name of a table whose indexes to retrieve\r
+ * @return A recordset\r
+ */\r
+ function &getIndexes($table = '') {\r
+ $this->clean($table);\r
+\r
+ $sql = "SELECT c2.relname, i.indisprimary, i.indisunique, pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef\r
+ FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\r
+ WHERE c.relname = '{$table}' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\r
+ ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname";\r
+\r
+ return $this->selectSet($sql);\r
+ }\r
\r
// Capabilities\r
function hasSchemas() { return true; }\r
/**\r
* Function library read in upon startup\r
*\r
- * $Id: lib.inc.php,v 1.3 2002/10/23 21:59:14 xzilla Exp $\r
+ * $Id: lib.inc.php,v 1.4 2002/11/18 04:57:34 chriskl Exp $\r
*/\r
\r
// Create Misc class references\r
|| !isset($confServers[$_SESSION['webdbServerID']])\r
){\r
include($appBase . '/login.php');\r
+ // Theme\r
+ echo "<style type=\"text/css\">\n<!--\n";\r
+ include("../themes/{$guiTheme}/global.css");\r
+ echo "\n-->\n</style>\n";\r
exit;\r
}\r
\r
* if you click on a database it shows a list of database objects in that
* database.
*
- * $Id: browser.php,v 1.12 2002/11/14 01:04:38 chriskl Exp $
+ * $Id: browser.php,v 1.13 2002/11/18 04:57:34 chriskl Exp $
*/
// Include application functions
while (!$schemas->EOF) {
$schemanode = $tree->add_folder($node, htmlspecialchars($schemas->f[$data->nspFields['nspname']]),
'schema.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]) . '&schema=' .
- urlencode($schemas->f[$data->nspFields['nspname']]), '_self');
+ urlencode($schemas->f[$data->nspFields['nspname']]), 'detail');
if ($data->hasTables()) {
- $tree->add_document($schemanode, $strTables, 'tables.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail', "../images/themes/{$guiTheme}/tables.gif");
+ $tables = &$localData->getTables();
+ $table_node = $tree->add_folder($schemanode, $strTables,
+ 'tables.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail');
+ while (!$tables->EOF) {
+ $tree->add_document($table_node, htmlspecialchars($tables->f[$data->tbFields['tbname']]),
+ 'tblproperties.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]) . '&table=' .
+ urlencode($tables->f[$data->tbFields['tbname']]), 'detail', "../images/themes/{$guiTheme}/tables.gif");
+ $tables->moveNext();
+ }
}
if ($data->hasViews())
$tree->add_document($schemanode, $strViews, 'views.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail', "../images/themes/{$guiTheme}/views.gif");
- /* if ($data->hasTriggers())
- $tree->add_document($node, $strTriggers, 'triggers.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]));
- if ($data->hasRules())
- $tree->add_document($node, $strRules, 'rules.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]));*/
if ($data->hasSequences())
$tree->add_document($schemanode, $strSequences, 'sequences.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail', "../images/themes/{$guiTheme}/sequences.gif");
if ($data->hasFunctions())
$tree->add_document($node, $strTypes, 'types.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail');
if ($data->hasAggregates())
$tree->add_document($node, $strAggregates, 'aggregates.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail');
- if ($data->hasIndicies())
- $tree->add_document($node, $strIndicies, 'indicies.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail');
}
} else {
$node = $tree->add_document($root, htmlspecialchars($databases->f[$data->dbFields['dbname']]),
/**\r
* Login screen\r
*\r
- * $Id: login.php,v 1.3 2002/05/15 09:57:55 chriskl Exp $\r
+ * $Id: login.php,v 1.4 2002/11/18 04:57:34 chriskl Exp $\r
*/\r
\r
// Include application functions\r
</head>\r
\r
<body>\r
- <h1><?= $appName ?> <?= $appVersion ?></h1>\r
- <table border="0" cellpadding="0" cellspacing="0" width="350">\r
+ <table class="navbar" border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">\r
<tr height="115">\r
<td height="115" align="center" valign="middle">\r
- <table border="0" cellpadding="2" cellspacing="0">\r
- <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" name="login_form">\r
+ <center>\r
+ <h1><?= $appName ?> <?= $strLogin ?></h1>\r
+ <table class="navbar" border="0" cellpadding="5" cellspacing="3">\r
+ <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" name="login_form"> \r
<tr>\r
- <td class="form">Username:</td>\r
+ <td>Username:</td>\r
<td><input type="text" name="formUsername" value="<?php isset($webdbUsername) ? htmlspecialchars($webdbUsername) : '' ?>" size="24"></td>\r
</tr>\r
<tr>\r
- <td class="form">Password:</td>\r
+ <td>Password:</td>\r
<td><input type="password" name="formPassword" size="24"></td>\r
</tr>\r
<tr>\r
- <td class="form">Server:</td>\r
+ <td>Server:</td>\r
<td><select name="formServer">\r
<?php\r
for ($i = 0; $i < sizeof($confServers); $i++) {\r
</tr>\r
</form>\r
</table>\r
+ </center>\r
<script language=javascript>\r
var uname = document.login_form.formUsername;\r
var pword = document.login_form.formPassword;\r
/**
* List tables in a database
*
- * $Id: tblproperties.php,v 1.6 2002/11/14 01:04:38 chriskl Exp $
+ * $Id: tblproperties.php,v 1.7 2002/11/18 04:57:34 chriskl Exp $
*/
// Include application functions
$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
$PHP_SELF = $_SERVER['PHP_SELF'];
+ function doIndicies($msg = '') {
+ global $data, $localData, $misc;
+ global $PHP_SELF;
+ global $strNoIndicies, $strIndicies, $strOwner, $strActions, $strName;
+
+ doNav();
+ echo "<h2>", htmlspecialchars($_REQUEST['database']), ": ", htmlspecialchars($_REQUEST['table']), ": {$strIndicies}</h2>\n";
+
+ $indexes = &$localData->getIndexes($_REQUEST['table']);
+
+ if ($indexes->recordCount() > 0) {
+ echo "<table>\n";
+ echo "<tr><th class=\"data\">{$strName}</th><th class=\"data\">Definition</th><th colspan=\"2\" class=\"data\">{$strActions}</th>\n";
+ $i = 0;
+
+ while (!$indexes->EOF) {
+ $id = ( ($i % 2 ) == 0 ? '1' : '2' );
+ echo "<tr><td class=\"data{$id}\">", htmlspecialchars( $indexes->f[$data->ixFields['idxname']]), "</td>";
+ echo "<td class=\"data{$id}\">", htmlspecialchars( $indexes->f[$data->ixFields['idxdef']]), "</td>";
+ echo "<td class=\"data{$id}\">";
+ echo "<a href=\"$PHP_SELF?action=confirm_drop&database=", htmlspecialchars($_REQUEST['database']), "&index=", htmlspecialchars( $indexes->f[$data->ixFields['idxname']]), "\">Drop</td>\n";
+ echo "<td class=\"data{$id}\">";
+ echo "<a href=\"$PHP_SELF?action=priviledges&database=", htmlspecialchars($_REQUEST['database']), "&index=", htmlspecialchars( $indexes->f[$data->ixFields['idxname']]), "\">Privileges</td></tr>\n";
+
+ $indexes->movenext();
+ $i++;
+ }
+
+ echo "</table>\n";
+ }
+ else
+ echo "<p>{$strNoIndicies}</p>\n";
+
+ echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=createindex&database=",
+ urlencode( $_REQUEST['database'] ), "&table=", htmlspecialchars($_REQUEST['table']), "\">Create Index</a></p>\n";
+ }
+
function doExport($msg = '') {
global $data, $localData, $misc;
global $PHP_SELF, $strExport;
echo "<table class=\"navbar\" border=\"0\" width=\"100%\" cellpadding=\"5\" cellspacing=\"3\">\n";
echo "<tr><td width=\"17%\"><a href=\"{$PHP_SELF}?{$vars}\">Columns</a></td>";
- echo "<td width=\"17%\"><a href=\"{$PHP_SELF}?{$vars}&action=indexes\">Indexes</a></td>";
+ echo "<td width=\"17%\"><a href=\"{$PHP_SELF}?{$vars}&action=indicies\">Indexes</a></td>";
echo "<td width=\"17%\"><a href=\"{$PHP_SELF}?{$vars}&action=constraints\">Constraints</a></td>";
echo "<td width=\"17%\"><a href=\"{$PHP_SELF}?{$vars}&action=triggers\">Triggers</a></td>";
echo "<td width=\"17%\"><a href=\"{$PHP_SELF}?{$vars}&action=rules\">Rules</a></td>";
echo "<body>\n";
switch ($action) {
+ case 'indicies':
+ doIndicies();
+ break;
case 'export':
doExport();
break;