* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.70 2003/03/27 13:47:15 chriskl Exp $
+ * $Id: Postgres.php,v 1.71 2003/04/08 12:45:18 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
// database encoding does not appear in this list, then its HTTP
// encoding name is the same as its database encoding name.
var $codemap = array(
+ 'ALT' => 'CP866',
+ 'EUC_CN' => 'GB2312',
+ 'EUC_JP' => 'EUCJP',
+ 'EUC_KR' => 'EUCKR',
+ 'EUC_TW' => 'EUCTW',
+ 'ISO_8859-5' => 'ISO 8859-5',
+ 'ISO_8859-6' => 'ISO 8859-6',
+ 'ISO_8859-7' => 'ISO 8859-7',
+ 'ISO_8859-8' => 'ISO 8859-8',
+ 'JOHAB' => 'CP1361',
+ 'KOI8' => 'KOI8-R',
+ 'LATIN1' => 'ISO 8859-1',
+ 'LATIN2' => 'ISO 8859-2',
+ 'LATIN3' => 'ISO 8859-3',
+ 'LATIN4' => 'ISO 8859-4',
+ // The following encoding map is a known error in PostgreSQL < 7.2
+ // See the constructor for Postgres72.
+ 'LATIN5' => 'ISO 8859-5',
+ 'LATIN6' => 'ISO 8859-10',
+ 'LATIN7' => 'ISO 8859-13',
+ 'LATIN8' => 'ISO 8859-14',
+ 'LATIN9' => 'ISO 8859-15',
+ 'LATIN10' => 'ISO 8859-16',
'SQL_ASCII' => 'ASCII',
- 'LATIN1' => 'ISO-8859-1',
- 'LATIN2' => 'ISO-8859-2',
- 'LATIN3' => 'ISO-8859-3',
- 'LATIN4' => 'ISO-8859-4',
- 'LATIN5' => 'ISO-8859-9',
- 'LATIN6' => 'ISO-8859-10',
- 'LATIN7' => 'ISO-8859-13',
- 'LATIN8' => 'ISO-8859-14',
- 'LATIN9' => 'ISO-8859-15',
- 'LATIN10' => 'ISO-8859-16',
- 'UNICODE' => 'UTF-8'
+ 'TCVN' => 'CP1258',
+ 'UNICODE' => 'UTF8',
+ 'WIN' => 'CP1251',
+ 'WIN874' => 'CP874',
+ 'WIN1256' => 'CP1256'
);
// List of all legal privileges that can be applied to different types
/**
* List constraints on a table
*
- * $Id: constraints.php,v 1.11 2003/03/26 01:24:17 chriskl Exp $
+ * $Id: constraints.php,v 1.12 2003/04/08 12:45:17 chriskl Exp $
*/
// Include application functions
$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
$PHP_SELF = $_SERVER['PHP_SELF'];
+
+ /**
+ * Confirm and then actually add a FOREIGN KEY constraint
+ */
+ function addForeignKey($stage, $msg = '') {
+ global $PHP_SELF, $data, $localData, $misc;
+ global $lang;
+
+ if (!isset($_POST['name'])) $_POST['name'] = '';
+ if (!isset($_POST['target'])) $_POST['target'] = '';
+
+ switch ($stage) {
+ case 2:
+ echo "<h2>", htmlspecialchars($_REQUEST['database']), ": {$lang['strtables']}: ",
+ htmlspecialchars($_REQUEST['table']), ": {$lang['straddfk']}</h2>\n";
+ $misc->printMsg($msg);
+
+ $attrs = &$localData->getTableAttributes($_REQUEST['target']);
+
+ $selColumns = new XHTML_select('TableColumnList', true, 10);
+ $selColumns->set_style('width: 10em;');
+
+ if ($attrs->recordCount() > 0) {
+ while (!$attrs->EOF) {
+ $selColumns->add(new XHTML_Option($attrs->f['attname']));
+ $attrs->moveNext();
+ }
+ }
+
+ $selIndex = new XHTML_select('IndexColumnList[]', true, 10);
+ $selIndex->set_style('width: 10em;');
+ $selIndex->set_attribute('id', 'IndexColumnList');
+ $buttonAdd = new XHTML_Button('add', '>>');
+ $buttonAdd->set_attribute('onclick', 'buttonPressed(this);');
+ $buttonAdd->set_attribute('type', 'button');
+
+ $buttonRemove = new XHTML_Button('remove', '<<');
+ $buttonRemove->set_attribute('onclick', 'buttonPressed(this);');
+ $buttonRemove->set_attribute('type', 'button');
+
+ echo "<form onsubmit=\"doSelectAll();\" name=\"formIndex\" action=\"$PHP_SELF\" method=\"post\">\n";
+
+ echo "<table>\n";
+ echo "<tr><th class=\"data\" colspan=\"3\">{$lang['strname']}</th></tr>";
+ echo "<tr>";
+ echo "<td class=\"data1\" colspan=\"3\"><input type=\"text\" name=\"name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" /></td></tr>";
+ echo "<tr><th class=\"data\">{$lang['strtablecolumnlist']}</th><th class=\"data\"> </th><th class=data>{$lang['strindexcolumnlist']}</th></tr>\n";
+ echo "<tr><td class=\"data1\">" . $selColumns->fetch() . "</td>\n";
+ echo "<td class=\"data1\" align=\"center\">" . $buttonRemove->fetch() . $buttonAdd->fetch() . "</td>";
+ echo "<td class=data1>" . $selIndex->fetch() . "</td></tr>\n";
+ echo "<tr><th class=\"data\" colspan=\"3\">{$lang['strfktarget']}</th></tr>";
+ echo "<tr>";
+ echo "<td class=\"data1\" colspan=\"3\"><input type=\"text\" name=\"target\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" /></td></tr>";
+ echo "</table>\n";
+
+ echo "<p><input type=\"hidden\" name=\"action\" value=\"save_add_foreign_key\">\n";
+ echo $misc->form;
+ echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\">\n";
+ echo "<input type=\"hidden\" name=\"name\" value=\"", htmlspecialchars($_REQUEST['name']), "\">\n";
+ echo "<input type=\"hidden\" name=\"target\" value=\"", htmlspecialchars($_REQUEST['target']), "\">\n";
+ echo "<input type=\"hidden\" name=\"IndexColumnList\" value=\"", htmlspecialchars(serialize($_REQUEST['IndexColumnList'])), "\">\n";
+ echo "<input type=\"hidden\" name=\"stage\" value=\"3\">\n";
+ echo "<input type=\"submit\" value=\"{$lang['stradd']}\"> <input type=\"reset\" value=\"{$lang['strreset']}\"></p>\n";
+ echo "</form>\n";
+
+ echo "<p><a class=\"navlink\" href=\"$PHP_SELF?{$misc->href}&table=", urlencode($_REQUEST['table']),
+ "\">{$lang['strshowallconstraints']}</a></p>\n";
+ break;
+ default:
+ echo "<h2>", htmlspecialchars($_REQUEST['database']), ": {$lang['strtables']}: ",
+ htmlspecialchars($_REQUEST['table']), ": {$lang['straddfk']}</h2>\n";
+ $misc->printMsg($msg);
+
+ $attrs = &$localData->getTableAttributes($_REQUEST['table']);
+
+ $selColumns = new XHTML_select('TableColumnList', true, 10);
+ $selColumns->set_style('width: 10em;');
+
+ if ($attrs->recordCount() > 0) {
+ while (!$attrs->EOF) {
+ $selColumns->add(new XHTML_Option($attrs->f['attname']));
+ $attrs->moveNext();
+ }
+ }
+
+ $selIndex = new XHTML_select('IndexColumnList[]', true, 10);
+ $selIndex->set_style('width: 10em;');
+ $selIndex->set_attribute('id', 'IndexColumnList');
+ $buttonAdd = new XHTML_Button('add', '>>');
+ $buttonAdd->set_attribute('onclick', 'buttonPressed(this);');
+ $buttonAdd->set_attribute('type', 'button');
+
+ $buttonRemove = new XHTML_Button('remove', '<<');
+ $buttonRemove->set_attribute('onclick', 'buttonPressed(this);');
+ $buttonRemove->set_attribute('type', 'button');
+
+ echo "<form onsubmit=\"doSelectAll();\" name=\"formIndex\" action=\"$PHP_SELF\" method=\"post\">\n";
+
+ echo "<table>\n";
+ echo "<tr><th class=\"data\" colspan=\"3\">{$lang['strname']}</th></tr>";
+ echo "<tr>";
+ echo "<td class=\"data1\" colspan=\"3\"><input type=\"text\" name=\"name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" /></td></tr>";
+ echo "<tr><th class=\"data\">{$lang['strtablecolumnlist']}</th><th class=\"data\"> </th><th class=data>{$lang['strindexcolumnlist']}</th></tr>\n";
+ echo "<tr><td class=\"data1\">" . $selColumns->fetch() . "</td>\n";
+ echo "<td class=\"data1\" align=\"center\">" . $buttonRemove->fetch() . $buttonAdd->fetch() . "</td>";
+ echo "<td class=data1>" . $selIndex->fetch() . "</td></tr>\n";
+ echo "<tr><th class=\"data\" colspan=\"3\">{$lang['strfktarget']}</th></tr>";
+ echo "<tr>";
+ echo "<td class=\"data1\" colspan=\"3\"><input type=\"text\" name=\"target\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" /></td></tr>";
+ echo "</table>\n";
+
+ echo "<p><input type=\"hidden\" name=\"action\" value=\"save_add_foreign_key\">\n";
+ echo $misc->form;
+ echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\">\n";
+ echo "<input type=\"hidden\" name=\"stage\" value=\"2\">\n";
+ echo "<input type=\"submit\" value=\"{$lang['stradd']}\"> <input type=\"reset\" value=\"{$lang['strreset']}\"></p>\n";
+ echo "</form>\n";
+
+ echo "<p><a class=\"navlink\" href=\"$PHP_SELF?{$misc->href}&table=", urlencode($_REQUEST['table']),
+ "\">{$lang['strshowallconstraints']}</a></p>\n";
+ break;
+ }
+
+ }
+
/**
* Confirm and then actually add a PRIMARY KEY or UNIQUE constraint
*/
echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=add_unique_key&{$misc->href}&table=", urlencode($_REQUEST['table']),
"\">{$lang['stradduniq']}</a> |\n";
echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=add_primary_key&{$misc->href}&table=", urlencode($_REQUEST['table']),
- "\">{$lang['straddpk']}</a></p>\n";
+ "\">{$lang['straddpk']}</a> |\n";
+ echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=add_foreign_key&{$misc->href}&table=", urlencode($_REQUEST['table']),
+ "\">{$lang['straddfk']}</a></p>\n";
}
$misc->printHeader($lang['strtables'] . ' - ' . $_REQUEST['table'] . ' - ' . $lang['strconstraints'],
$misc->printBody();
switch ($action) {
+ case 'add_foreign_key':
+ addForeignKey(1);
+ break;
+ case 'save_add_foreign_key':
+ if (isset($_POST['cancel'])) doDefault();
+ else addForeignKey($_REQUEST['stage']);
+ break;
case 'add_unique_key':
addPrimaryOrUniqueKey('unique', true);
break;