phpPgAdmin History
------------------
+Version 3.0.0-dev-5
+-------------------
+
+* Cascade drop on columns and constraints
+
Version 3.0.0-dev-4
-------------------
-------------------
* French translation
-* Russion translations
+* Russian translations
* Japanese translations
* Trigger definitions
* ADODB upgrade
/*
* Parent class of all ADODB objects.
*
- * $Id: ADODB_base.php,v 1.11 2003/03/27 13:47:15 chriskl Exp $
+ * $Id: ADODB_base.php,v 1.12 2003/05/01 03:27:54 chriskl Exp $
*/
include_once('libraries/errorhandler.inc.php');
else $values = ") VALUES ('{$value}'";
}
$sql = $fields . $values . ')';
- } else {
- // @@ THIS IS TOTALLY WRONG!!!
- $sql = "INSERT INTO \"{$table}\" DEFAULT VALUES";
}
// Check for failures
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: BaseDB.php,v 1.13 2003/04/30 06:35:41 chriskl Exp $
+ * $Id: BaseDB.php,v 1.14 2003/05/01 03:27:54 chriskl Exp $
*/
include_once('classes/database/ADODB_base.php');
* @return 0 success
* @return -1 invalid parameters
*/
- function insertRow($table, $values, $nulls) {
- if (!is_array($values) || !is_array($nulls)) return -1;
+ function insertRow($table, $vars, $nulls) {
+ if (!is_array($vars) || !is_array($nulls)) return -1;
// @@ WE CANNOT USE insert AS WE NEED TO NOT QUOTE SOME THINGS
// @@ WHAT ABOUT BOOLEANS??
else {
- $temp = array();
- foreach($values as $k => $v) {
- if (!isset($nulls[$k])) $temp[$k] = $v;
- }
- return $this->insert($table, $temp);
+ $this->fieldClean($table);
+
+ // Build clause
+ if (sizeof($vars) > 0) {
+ $fields = '';
+ $values = '';
+ foreach($vars as $key => $value) {
+ $this->clean($key);
+ $this->clean($value);
+
+ if ($fields) $fields .= ", \"{$key}\"";
+ else $fields = "INSERT INTO \"{$table}\" (\"{$key}\"";
+
+ // Handle NULL values
+ if (isset($nulls[$key])) $tmp = 'NULL';
+ else $tmp = "'{$value}'";
+
+ if ($values) $values .= ", {$tmp}";
+ else $values = ") VALUES ({$tmp}";
+ }
+ $sql = $fields . $values . ')';
+ }
+ return $this->execute($sql);
}
}
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.88 2003/04/30 07:42:58 chriskl Exp $
+ * $Id: Postgres.php,v 1.89 2003/05/01 03:27:54 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
* Drops a column from a table
* @param $table The table from which to drop a column
* @param $column The column to be dropped
- * @param $behavior CASCADE or RESTRICT or empty
+ * @param $cascade True to cascade drop, false to restrict
* @return 0 success
* @return -99 not implemented
*/
- function dropColumn($table, $column, $behavior) {
+ function dropColumn($table, $column, $cascade) {
return -99;
}
return $this->execute($sql);
}
- /**
- * Drops a column from a table
- * @param $table The table from which to drop
- * @param $column The column name to drop
- * @return 0 success
- */
- function dropColumnFromTable($table, $column) {
- return -99; // Not implemented
- }
-
/**
* Sets default value of a column
* @param $table The table from which to drop
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres72.php,v 1.36 2003/04/30 06:49:12 chriskl Exp $
+ * $Id: Postgres72.php,v 1.37 2003/05/01 03:27:54 chriskl Exp $
*/
* Removes a constraint from a relation
* @param $constraint The constraint to drop
* @param $relation The relation from which to drop
+ * @param $cascade True to cascade drop, false to restrict
* @return 0 success
*/
- function dropConstraint($constraint, $relation) {
+ function dropConstraint($constraint, $relation, $cascade) {
$this->fieldClean($constraint);
$this->fieldClean($relation);
$sql = "ALTER TABLE \"{$relation}\" DROP CONSTRAINT \"{$constraint}\" RESTRICT";
+ if ($cascade) $sql .= " CASCADE";
return $this->execute($sql);
}
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres73.php,v 1.38 2003/04/30 07:28:11 chriskl Exp $
+ * $Id: Postgres73.php,v 1.39 2003/05/01 03:27:54 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
* Drops a column from a table
* @param $table The table from which to drop a column
* @param $column The column to be dropped
- * @param $behavior CASCADE or RESTRICT or empty
+ * @param $cascade True to cascade drop, false to restrict
* @return 0 success
*/
- function dropColumn($table, $column, $behavior) {
- $this->clean($table);
- $this->clean($column);
- $this->clean($behavior);
+ function dropColumn($table, $column, $cascade) {
+ $this->fieldClean($table);
+ $this->fieldClean($column);
- $sql = "ALTER TABLE \"{$table}\" DROP COLUMN \"{$column}\" " .
- (($behavior == 'CASCADE') ? 'CASCADE' : 'RESTRICT');
+ $sql = "ALTER TABLE \"{$table}\" DROP COLUMN \"{$column}\"";
+ if ($cascade) $sql .= " CASCADE";
return $this->execute($sql);
}
* @return 0 success
*/
function setColumnNull($table, $column, $state) {
- $this->clean($table);
- $this->clean($column);
-
- $sql = "ALTER TABLE \"{$table}\" ALTER COLUMN \"{$column}\" " . (($state) ? 'DROP' : 'SET') . " NOT NULL";
-
- return $this->execute($sql);
- }
-
- // Constraint functions
-
- /**
- * Drops a unique constraint from a table
- * @param $table The table from which to drop the unique key
- * @param $name The name of the unique key
- * @return 0 success
- */
- function dropUniqueKey($table, $name) {
$this->fieldClean($table);
- $this->fieldClean($name);
-
- $sql = "ALTER TABLE \"{$table}\" DROP CONSTRAINT \"{$name}\"";
+ $this->fieldClean($column);
- return $this->execute($sql);
- }
-
- /**
- * Drops a primary key constraint from a table
- * @param $table The table from which to drop the primary key
- * @param $name The name of the primary key
- * @return 0 success
- */
- function dropPrimaryKey($table, $name) {
- $this->fieldClean($table);
- $this->fieldClean($name);
-
- $sql = "ALTER TABLE \"{$table}\" DROP CONSTRAINT \"{$name}\"";
+ $sql = "ALTER TABLE \"{$table}\" ALTER COLUMN \"{$column}\" " . (($state) ? 'DROP' : 'SET') . " NOT NULL";
return $this->execute($sql);
}
* Removes a constraint from a relation
* @param $constraint The constraint to drop
* @param $relation The relation from which to drop
+ * @param $cascade True to cascade drop, false to restrict
* @return 0 success
*/
- function dropConstraint($constraint, $relation) {
+ function dropConstraint($constraint, $relation, $cascade) {
$this->fieldClean($constraint);
$this->fieldClean($relation);
$sql = "ALTER TABLE \"{$relation}\" DROP CONSTRAINT \"{$constraint}\"";
+ if ($cascade) $sql .= " CASCADE";
return $this->execute($sql);
}
/**
* List constraints on a table
*
- * $Id: constraints.php,v 1.14 2003/04/23 08:56:26 chriskl Exp $
+ * $Id: constraints.php,v 1.15 2003/05/01 03:27:54 chriskl Exp $
*/
// Include application functions
echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\">\n";
echo "<input type=\"hidden\" name=\"constraint\" value=\"", htmlspecialchars($_REQUEST['constraint']), "\">\n";
echo $misc->form;
+ // Show cascade drop option if supportd
+ if ($localData->hasDropBehavior()) {
+ echo "<p><input type=\"checkbox\" name=\"cascade\"> {$lang['strcascade']}</p>\n";
+ }
echo "<input type=\"submit\" name=\"choice\" value=\"{$lang['stryes']}\"> <input type=\"submit\" name=\"choice\" value=\"{$lang['strno']}\">\n";
echo "</form>\n";
}
else {
- $status = $localData->dropConstraint($_POST['constraint'], $_POST['table']);
+ $status = $localData->dropConstraint($_POST['constraint'], $_POST['table'], isset($_POST['cascade']));
if ($status == 0)
doDefault($lang['strconstraintdropped']);
else
/**
* List tables in a database
*
- * $Id: tblproperties.php,v 1.13 2003/04/20 09:45:39 chriskl Exp $
+ * $Id: tblproperties.php,v 1.14 2003/05/01 03:27:54 chriskl Exp $
*/
// Include application functions
echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
echo "<input type=\"hidden\" name=\"column\" value=\"", htmlspecialchars($_REQUEST['column']), "\" />\n";
echo $misc->form;
- echo "<input type=\"submit\" name=\"choice\" value=\"{$lang['stryes']}\" /> <input type=\"submit\" name=\"choice\" value=\"{$lang['strno']}\" />\n";
+ // Show cascade drop option if supportd
+ if ($localData->hasDropBehavior()) {
+ echo "<p><input type=\"checkbox\" name=\"cascade\"> {$lang['strcascade']}</p>\n";
+ }
+ echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" /> <input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\" />\n";
echo "</form>\n";
}
else {
- $status = $localData->dropColumn($_POST['table'], $_POST['column'], 'RESTRICT');
+ $status = $localData->dropColumn($_POST['table'], $_POST['column'], isset($_POST['cascade']));
if ($status == 0)
doDefault($lang['strcolumndropped']);
else
doProperties();
break;
case 'drop':
- if ($_POST['choice'] == "{$lang['stryes']}") doDrop(false);
+ if (isset($_POST['yes'])) doDrop(false);
else doDefault();
break;
case 'confirm_drop':