* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres74.php,v 1.71 2007/12/28 16:21:25 ioguix Exp $
+ * $Id: Postgres74.php,v 1.72 2008/02/20 21:06:18 ioguix Exp $
*/
include_once('./classes/database/Postgres73.php');
/**
* Creates a new table in the database copying attribs and other properties from another table
* @param $name The name of the table
- * @param $like The name of the table from which attribs are copying from
+ * @param $like an array giving the schema ans the name of the table from which attribs are copying from:
+ * array(
+ * 'table' => table name,
+ * 'schema' => the schema name,
+ * )
* @param $defaults if true, copy the defaults values as well
* @param $constraints if true, copy the constraints as well (CHECK on table & attr)
* @param $tablespace The tablespace name ('' means none/default)
*/
function createTableLike($name, $like, $defaults = false, $constraints = false, $idx = false, $tablespace = '') {
$this->fieldClean($name);
- $this->fieldClean($like);
+
+ $this->fieldClean($like['schema']);
+ $this->fieldClean($like['table']);
+ $like = "\"{$like['schema']}\".\"{$like['table']}\"";
$status = $this->beginTransaction();
if ($status != 0) return -1;
/**
* List tables in a database
*
- * $Id: tables.php,v 1.109 2008/01/14 17:55:01 ioguix Exp $
+ * $Id: tables.php,v 1.110 2008/02/20 21:06:18 ioguix Exp $
*/
// Include application functions
while (!$tablespaces->EOF) {
$spcname = htmlspecialchars($tablespaces->fields['spcname']);
echo "\t\t\t\t<option value=\"{$spcname}\"",
- ($spcname == $_REQUEST['spcname']) ? ' selected="selected"' : '', ">{$spcname}</option>\n";
+ ($tablespaces->fields['spcname'] == $_REQUEST['spcname']) ? ' selected="selected"' : '', ">{$spcname}</option>\n";
$tablespaces->moveNext();
}
echo "\t\t\t</select>\n\t\t</td>\n\t</tr>\n";
/**
* Dsiplay a screen where user can create a table from an existing one.
+ * We don't have to check if pg supports schema cause create table like
+ * is available under pg 7.4+ which has schema.
*/
function doCreateLike($confirm, $msg = '') {
global $data, $misc, $lang;
$tbltmp = $tbltmp->getArray();
$tables = array();
- if ( $data->hasSchemas() )
- foreach ($tbltmp as $a) $tables["{$a['nspname']}.{$a['relname']}"] = "{$a['nspname']}.{$a['relname']}";
- else
- foreach ($tbltmp as $a) $tables[$a['relname']] = $a['relname'];
+ foreach ($tbltmp as $a) {
+ $data->fieldClean($a['nspname']);
+ $data->fieldClean($a['relname']);
+ $tables["\"{$a['nspname']}\".\"{$a['relname']}\""] = serialize(array('schema' => $a['nspname'], 'table' => $a['relname']));
+ }
unset($tbltmp);
isset($_REQUEST['withdefaults']) ? ' checked="checked"' : '',
"/>{$lang['strcreatelikewithdefaults']}</label>";
if ($data->hasCreateTableLikeWithConstraints()) {
- echo "<label for=\"withconstraints\"><input type=\"checkbox\" id=\"withconstraints\" name=\"withconstraints\"",
+ echo "<br /><label for=\"withconstraints\"><input type=\"checkbox\" id=\"withconstraints\" name=\"withconstraints\"",
isset($_REQUEST['withconstraints']) ? ' checked="checked"' : '',
"/>{$lang['strcreatelikewithconstraints']}</label>";
}
if ($data->hasCreateTableLikeWithIndexes()) {
- echo "<label for=\"withindexes\"><input type=\"checkbox\" id=\"withindexes\" name=\"withindexes\"",
+ echo "<br /><label for=\"withindexes\"><input type=\"checkbox\" id=\"withindexes\" name=\"withindexes\"",
isset($_REQUEST['withindexes']) ? ' checked="checked"' : '',
"/>{$lang['strcreatelikewithindexes']}</label>";
}
if (!isset($_REQUEST['tablespace'])) $_REQUEST['tablespace'] = '';
- $status = $data->createTableLike($_REQUEST['name'], $_REQUEST['like'], isset($_REQUEST['withdefaults']),
- isset($_REQUEST['withconstraints']), isset($_REQUEST['withindexes']), $_REQUEST['tablespace']);
+ $status = $data->createTableLike($_REQUEST['name'], unserialize($_REQUEST['like']), isset($_REQUEST['withdefaults']),
+ isset($_REQUEST['withconstraints']), isset($_REQUEST['withindexes']), $_REQUEST['tablespace']);
+
if ($status == 0) {
$_reload_browser = true;
doDefault($lang['strtablecreated']);