refactored complete table/column creation altering;

register_globals independent;
fixed bug #1344768 [database] create/alter table new field can not have empty string as default;
tweaked form layout to save space;
This commit is contained in:
Sebastian Mendel
2008-05-07 12:35:00 +00:00
parent 14edea6b1a
commit 206f4add2f
7 changed files with 526 additions and 494 deletions

View File

@@ -33,6 +33,8 @@ danbarry
- bug #1845605 [i18n] translators.html still uses iso-8859-1
- bug #1823018 [charset] Edit(Delete) img-links pointing to wrong row
- bug #1826205 [export] Problems with yaml text export
- bug #1344768 [database] create/alter table new field can not have empty string
as default
+ rfe #1840165 [interface] Enlarge column name field in vertical mode
+ patch #1847534 [interface] New "Inside field" in db search,
thanks to obiserver
@@ -63,6 +65,7 @@ danbarry
- bug #1955386 [session] Overriding session.hash_bits_per_character
- [interface] sanitize the table comments in table print view,
thanks to Norman Hippert
- bug #1939031 Auto_Increment selected for TimeStamp by Default
- bug #1910621 [display] part 2: do not display a BINARY content as text
2.11.6.0 (2008-04-29)

View File

@@ -259,27 +259,23 @@ class PMA_Table {
* @param string $attribute
* @param string $collation
* @param string $null with 'NULL' or 'NOT NULL'
* @param string $default default value
* @param boolean $default_current_timestamp whether default value is
* CURRENT_TIMESTAMP or not
* this overrides $default value
* @param string $default_type whether default is CURRENT_TIMESTAMP,
* NULL, NONE, USER_DEFINED
* @param boolean $default_value default value for USER_DEFINED default type
* @param string $extra 'AUTO_INCREMENT'
* @param string $comment field comment
* @param array &$field_primary list of fields for PRIMARY KEY
* @param string $index
* @param string $default_orig
* @return string field specification
*/
static function generateFieldSpec($name, $type, $length = '', $attribute = '',
$collation = '', $null = false, $default = '',
$default_current_timestamp = false, $extra = '', $comment = '',
$collation = '', $null = false, $default_type = 'USER_DEFINED',
$default_value = '', $extra = '', $comment = '',
&$field_primary, $index, $default_orig = false)
{
$is_timestamp = strpos(' ' . strtoupper($type), 'TIMESTAMP') == 1;
// $default_current_timestamp has priority over $default
/**
* @todo include db-name
*/
@@ -307,22 +303,25 @@ class PMA_Table {
}
}
if ($default_current_timestamp && $is_timestamp) {
$query .= ' DEFAULT CURRENT_TIMESTAMP';
// auto_increment field cannot have a default value
} elseif ($extra !== 'AUTO_INCREMENT'
&& $default !== false) {
if (strtoupper($default) == 'NULL') {
$query .= ' DEFAULT NULL';
} elseif ($is_timestamp && $default === '0') {
// a TIMESTAMP does not accept DEFAULT '0'
// but DEFAULT 0 works
$query .= ' DEFAULT ' . PMA_sqlAddslashes($default);
} elseif ($type == 'BIT') {
$query .= ' DEFAULT b\'' . preg_replace('/[^01]/', '0', $default) . '\'';
} else {
$query .= ' DEFAULT \'' . PMA_sqlAddslashes($default) . '\'';
}
switch ($default_type) {
case 'USER_DEFINED' :
if ($is_timestamp && $default_value === '0') {
// a TIMESTAMP does not accept DEFAULT '0'
// but DEFAULT 0 works
$query .= ' DEFAULT 0';
} elseif ($type == 'BIT') {
$query .= ' DEFAULT b\'' . preg_replace('/[^01]/', '0', $default_value) . '\'';
} else {
$query .= ' DEFAULT \'' . PMA_sqlAddslashes($default_value) . '\'';
}
break;
case 'NULL' :
case 'CURRENT_TIMESTAMP' :
$query .= ' DEFAULT ' . $default_type;
break;
case 'NONE' :
default :
break;
}
if (!empty($extra)) {
@@ -440,15 +439,15 @@ class PMA_Table {
} // end of the 'PMA_Table::countRecords()' function
/**
* @todo add documentation
* @see PMA_Table::generateFieldSpec()
*/
static public function generateAlter($oldcol, $newcol, $type, $length,
$attribute, $collation, $null, $default, $default_current_timestamp,
$extra, $comment='', &$field_primary, $index, $default_orig)
$attribute, $collation, $null, $default_type, $default_value,
$extra, $comment = '', &$field_primary, $index, $default_orig)
{
return PMA_backquote($oldcol) . ' '
. PMA_Table::generateFieldSpec($newcol, $type, $length, $attribute,
$collation, $null, $default, $default_current_timestamp, $extra,
$collation, $null, $default_type, $default_value, $extra,
$comment, $field_primary, $index, $default_orig);
} // end function

View File

@@ -1,8 +1,9 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Display form for changing/adding table field/columns
* Display form for changing/adding table fields/columns
*
* included by tbl_addfield.php, -_alter.php, -_create.php
* @version $Id$
*/
@@ -40,20 +41,20 @@ $_form_params = array(
if ($action == 'tbl_create.php') {
$_form_params['reload'] = 1;
} elseif ($action == 'tbl_addfield.php') {
$_form_params['field_where'] = $field_where;
$_form_params['after_field'] = $after_field;
$_form_params['field_where'] = $_REQUEST['field_where'];
$_form_params['after_field'] = $_REQUEST['after_field'];
}
if (isset($num_fields)) {
$_form_params['orig_num_fields'] = $num_fields;
}
if (isset($field_where)) {
$_form_params['orig_field_where'] = $field_where;
if (isset($_REQUEST['field_where'])) {
$_form_params['orig_field_where'] = $_REQUEST['field_where'];
}
if (isset($after_field)) {
$_form_params['orig_after_field'] = $after_field;
if (isset($_REQUEST['after_field'])) {
$_form_params['orig_after_field'] = $_REQUEST['after_field'];
}
if (isset($selected) && is_array($selected)) {
@@ -69,12 +70,12 @@ if (isset($selected) && is_array($selected)) {
$_form_params['true_selected[' . $o_fld_nr . ']'] = $o_fld_val;
}
}
} elseif (isset($field)) {
$_form_params['orig_field'] = $field;
} elseif (isset($_REQUEST['field'])) {
$_form_params['orig_field'] = $_REQUEST['field'];
if (isset($orig_field)) {
$_form_params['true_selected[]'] = $orig_field;
} else {
$_form_params['true_selected[]'] = $field;
$_form_params['true_selected[]'] = $_REQUEST['field'];
}
}
@@ -84,28 +85,27 @@ $header_cells = array();
$content_cells = array();
$header_cells[] = $strField;
$header_cells[] = $strType . ($GLOBALS['cfg']['ReplaceHelpImg'] ? PMA_showMySQLDocu('SQL-Syntax', 'data-types') : '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'data-types') . '</span>');
$header_cells[] = $strType
. ($GLOBALS['cfg']['ReplaceHelpImg']
? PMA_showMySQLDocu('SQL-Syntax', 'data-types')
: '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'data-types')
. '</span>');
$header_cells[] = $strLengthSet . PMA_showHint($strSetEnumVal);
$header_cells[] = $strDefault . PMA_showHint($strDefaultValueHelp);
$header_cells[] = $strCollation;
$header_cells[] = $strAttr;
$header_cells[] = $strNull;
$header_cells[] = $strDefault . PMA_showHint($strDefaultValueHelp);
$header_cells[] = $strExtra;
// lem9: We could remove this 'if' and let the key information be shown and
// editable. However, for this to work, tbl_alter must be modified to use the
// key fields, as tbl_addfield does.
if (!$is_backup) {
$header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_primary.png" width="16" height="16" alt="' . $strPrimary . '" title="' . $strPrimary . '" />' : $strPrimary;
$header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_index.png" width="16" height="16" alt="' . $strIndex . '" title="' . $strIndex . '" />' : $strIndex;
$header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_unique.png" width="16" height="16" alt="' . $strUnique . '" title="' . $strUnique . '" />' : $strUnique;
$header_cells[] = '---';
$header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_ftext.png" width="16" height="16" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' : $strIdxFulltext;
$header_cells[] = $strIndex;
}
$header_cells[] = '<abbr title="AUTO_INCREMENT">A_I</abbr>';
require_once './libraries/relation.lib.php';
require_once './libraries/transformations.lib.php';
$cfgRelation = PMA_getRelationsParam();
@@ -130,91 +130,138 @@ if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
$header_cells[] = $strMIME_MIMEtype;
$header_cells[] = $strMIME_transformation;
$header_cells[] = $strMIME_transformation_options . PMA_showHint($strMIME_transformation_options_note . $hint);
$header_cells[] = $strMIME_transformation_options
. PMA_showHint($strMIME_transformation_options_note . $hint);
}
// garvin: workaround for field_fulltext, because its submitted indizes contain
// the index as a value, not a key. Inserted here for easier maintaineance
// and less code to change in existing files.
if (isset($field_fulltext) && is_array($field_fulltext)) {
foreach ($field_fulltext AS $fulltext_nr => $fulltext_indexkey) {
foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) {
$submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
}
}
for ($i = 0; $i <= $num_fields; $i++) {
for ($i = 0; $i < $num_fields; $i++) {
if (! empty($regenerate)) {
// An error happened with previous inputs, so we will restore the data
// to embed it once again in this form.
$row['Field'] = (isset($field_name[$i]) ? $field_name[$i] : FALSE);
$row['Type'] = (isset($field_type[$i]) ? $field_type[$i] : FALSE);
$row['Collation'] = (isset($field_collation[$i]) ? $field_collation[$i] : '');
$row['Null'] = (isset($field_null[$i]) ? $field_null[$i] : '');
$row['Field'] = (isset($_REQUEST['field_name'][$i]) ? $_REQUEST['field_name'][$i] : false);
$row['Type'] = (isset($_REQUEST['field_type'][$i]) ? $_REQUEST['field_type'][$i] : false);
$row['Collation'] = (isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '');
$row['Null'] = (isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : '');
if (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'primary_' . $i) {
if (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'primary_' . $i) {
$row['Key'] = 'PRI';
} elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'index_' . $i) {
} elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'index_' . $i) {
$row['Key'] = 'MUL';
} elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'unique_' . $i) {
} elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'unique_' . $i) {
$row['Key'] = 'UNI';
} elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'fulltext_' . $i) {
$row['Key'] = 'FULLTEXT';
} else {
$row['Key'] = '';
}
$row['Default'] = (isset($field_default[$i]) ? $field_default[$i] : FALSE);
$row['Extra'] = (isset($field_extra[$i]) ? $field_extra[$i] : FALSE);
$row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : FALSE);
$row['DefaultType'] = (isset($_REQUEST['field_default_type'][$i]) ? $_REQUEST['field_default_type'][$i] : 'USER_DEFINED');
$row['DefaultValue'] = (isset($_REQUEST['field_default_value'][$i]) ? $_REQUEST['field_default_value'][$i] : '');
$submit_length = (isset($field_length[$i]) ? $field_length[$i] : FALSE);
$submit_attribute = (isset($field_attribute[$i]) ? $field_attribute[$i] : FALSE);
switch ($row['DefaultType']) {
case 'NONE' :
$row['Default'] = null;
break;
case 'USER_DEFINED' :
$row['Default'] = $row['DefaultValue'];
break;
case 'NULL' :
case 'CURRENT_TIMESTAMP' :
$row['Default'] = $row['DefaultType'];
break;
}
$row['Extra'] = (isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false);
$row['Comment'] = (isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : false);
$submit_default_current_timestamp = (isset($field_default_current_timestamp[$i]) ? TRUE : FALSE);
$submit_length = (isset($_REQUEST['field_length'][$i]) ? $_REQUEST['field_length'][$i] : false);
$submit_attribute = (isset($_REQUEST['field_attribute'][$i]) ? $_REQUEST['field_attribute'][$i] : false);
if (isset($field_comments[$i])) {
$comments_map[$row['Field']] = $field_comments[$i];
$submit_default_current_timestamp = (isset($_REQUEST['field_default_current_timestamp'][$i]) ? true : false);
if (isset($_REQUEST['field_comments'][$i])) {
$comments_map[$row['Field']] = $_REQUEST['field_comments'][$i];
}
if (isset($field_mimetype[$i])) {
$mime_map[$row['Field']]['mimetype'] = $field_mimetype[$i];
if (isset($_REQUEST['field_mimetype'][$i])) {
$mime_map[$row['Field']]['mimetype'] = $_REQUEST['field_mimetype'][$i];
}
if (isset($field_transformation[$i])) {
$mime_map[$row['Field']]['transformation'] = $field_transformation[$i];
if (isset($_REQUEST['field_transformation'][$i])) {
$mime_map[$row['Field']]['transformation'] = $_REQUEST['field_transformation'][$i];
}
if (isset($field_transformation_options[$i])) {
$mime_map[$row['Field']]['transformation_options'] = $field_transformation_options[$i];
if (isset($_REQUEST['field_transformation_options'][$i])) {
$mime_map[$row['Field']]['transformation_options'] = $_REQUEST['field_transformation_options'][$i];
}
} elseif (isset($fields_meta[$i])) {
$row = $fields_meta[$i];
switch ($row['Default']) {
case null:
if ($row['Null'] == 'YES') {
$row['DefaultType'] = 'NULL';
} else {
$row['DefaultType'] = 'NONE';
}
$row['DefaultValue'] = '';
break;
case 'CURRENT_TIMESTAMP':
$row['DefaultType'] = 'CURRENT_TIMESTAMP';
$row['DefaultValue'] = '';
break;
default:
$row['DefaultType'] = 'USER_DEFINED';
$row['DefaultValue'] = $row['Default'];
break;
}
}
if (isset($row) && isset($row['Type'])) {
if (isset($row['Type'])) {
$type_and_length = PMA_extract_type_length($row['Type']);
if ($type_and_length['type'] == 'bit') {
$row['Default'] = PMA_printable_bit_value($row['Default'], $type_and_length['length']);
}
}
// Cell index: If certain fields get left out, the counter shouldn't chage.
// Cell index: If certain fields get left out, the counter shouldn't change.
$ci = 0;
// Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
// has to be incremented ($ci_offset++)
$ci_offset = -1;
// old column name
if ($is_backup) {
$backup_field = (isset($true_selected) && isset($true_selected[$i]) && $true_selected[$i] ? $true_selected[$i] : (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : ''));
$content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_orig[]" value="' . $backup_field . '" />' . "\n";
} else {
$content_cells[$i][$ci] = '';
if (! empty($true_selected[$i])) {
$_form_params['field_orig[' . $i . ']'] = $true_selected[$i];
} elseif (isset($row['Field'])) {
$_form_params['field_orig[' . $i . ']'] = $row['Field'];
} else {
$_form_params['field_orig[' . $i . ']'] = '';
}
}
$content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_name[' . $i . ']" size="' . ($GLOBALS['cfg']['DefaultPropDisplay'] == 'horizontal' ? '10' : '30') . '" maxlength="64" value="' . (isset($row) && isset($row['Field']) ? str_replace('"', '&quot;', $row['Field']) : '') . '" class="textfield" title="' . $strField . '" />';
// column name
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
. ' type="text" name="field_name[' . $i . ']"'
. ' maxlength="64" class="textfield" title="' . $strField . '"'
. ' size="' . ($GLOBALS['cfg']['DefaultPropDisplay'] == 'horizontal' ? '10' : '30') . '"'
. ' value="' . (isset($row['Field']) ? htmlspecialchars($row['Field']) : '') . '"'
. ' />';
$ci++;
$content_cells[$i][$ci] = '<select name="field_type[' . $i . ']" id="field_' . $i . '_' . ($ci - $ci_offset) . '" ';
$content_cells[$i][$ci] .= 'onchange="display_field_options(this.options[this.selectedIndex].value,' . $i .')" ';
$content_cells[$i][$ci] .= '>' . "\n";
// column type
$content_cells[$i][$ci] = '<select name="field_type[' . $i . ']"'
.' id="field_' . $i . '_' . ($ci - $ci_offset) . '" >';
if (empty($row['Type'])) {
$row['Type'] = '';
@@ -247,7 +294,7 @@ for ($i = 0; $i <= $num_fields; $i++) {
$type = substr($type, 0, $tmp - 1);
}
if (isset($submit_length) && $submit_length != FALSE) {
if (isset($submit_length) && $submit_length != false) {
$length = $submit_length;
}
@@ -263,7 +310,7 @@ for ($i = 0; $i <= $num_fields; $i++) {
if ($type_upper == strtoupper($col_group_type)) {
$content_cells[$i][$ci] .= ' selected="selected"';
}
$content_cells[$i][$ci] .= '>' . $col_group_type . '</option>' . "\n";
$content_cells[$i][$ci] .= '>' . $col_group_type . '</option>';
}
$content_cells[$i][$ci] .= '</optgroup>';
continue;
@@ -273,18 +320,18 @@ for ($i = 0; $i <= $num_fields; $i++) {
if ($type_upper == strtoupper($column_type)) {
$content_cells[$i][$ci] .= ' selected="selected"';
}
$content_cells[$i][$ci] .= '>' . $column_type . '</option>' . "\n";
$content_cells[$i][$ci] .= '>' . $column_type . '</option>';
} // end for
$content_cells[$i][$ci] .= ' </select>';
$ci++;
// old column length
if ($is_backup) {
$content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_length_orig[' . $i . ']" value="' . urlencode($length) . '" />';
} else {
$content_cells[$i][$ci] = '';
$_form_params['field_length_orig[' . $i . ']'] = $length;
}
// column length
if (preg_match('@^(set|enum)$@i', $type)) {
$binary = 0;
$unsigned = 0;
@@ -292,20 +339,75 @@ for ($i = 0; $i <= $num_fields; $i++) {
$length_to_display = htmlspecialchars($length);
} else {
$length_to_display = $length;
$binary = FALSE;
$binary = false;
$unsigned = stristr($row['Type'], 'unsigned');
$zerofill = stristr($row['Type'], 'zerofill');
}
$content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_length[' . $i . ']" size="8" value="' . str_replace('"', '&quot;', $length_to_display) . '" class="textfield" />' . "\n";
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
. ' type="text" name="field_length[' . $i . ']" size="8"'
. ' value="' . htmlspecialchars($length_to_display) . '"'
. ' class="textfield" />';
$ci++;
// column default
/**
* having NULL enabled does not implicit having Default with NULL
*
if (isset($row)
&& !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
$row['Default'] = 'NULL';
}
*/
// old column default
if ($is_backup) {
$_form_params['field_default_orig[' . $i . ']'] =
(isset($row['Default']) ? $row['Default'] : '');
}
$default_options = array(
'USER_DEFINED' => 'strUserDefined',
'NONE' => $strNone,
'NULL' => 'NULL',
'CURRENT_TIMESTAMP' => 'CURRENT_TIMESTAMP',
);
// for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
if ($type_upper == 'TIMESTAMP'
&& $default_current_timestamp
&& isset($row['Default'])) {
$row['Default'] = '';
}
$content_cells[$i][$ci] = '<select name="field_default_type[' . $i . ']">';
foreach ($default_options as $key => $value) {
$content_cells[$i][$ci] .= '<option value="' . $key . '"';
if (($row['DefaultType']) == $key) {
$content_cells[$i][$ci] .= ' selected="selected"';
}
$content_cells[$i][$ci] .= ' >' . $value . '</option>';
}
$content_cells[$i][$ci] .= '</select>';
$content_cells[$i][$ci] .= '<br />';
$content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
. ' type="text" name="field_default_value[' . $i . ']" size="12"'
. ' value="' . (isset($row['DefaultValue']) ? htmlspecialchars($row['DefaultValue']) : '') . '"'
. ' class="textfield" />';
$ci++;
// column collation
$tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
$content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']', 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, FALSE);
$content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(
PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $i . ']',
'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, false);
unset($tmp_collation);
$ci++;
$content_cells[$i][$ci] = '<select style="font-size: 70%;" name="field_attribute[' . $i . ']" id="field_' . $i . '_' . ($ci - $ci_offset) . '">' . "\n";
// column attribute
$content_cells[$i][$ci] = '<select style="font-size: 70%;"'
. ' name="field_attribute[' . $i . ']"'
. ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
$attribute = '';
if ($binary) {
@@ -317,8 +419,11 @@ for ($i = 0; $i <= $num_fields; $i++) {
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
}
if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
$attribute = 'on update CURRENT_TIMESTAMP';
}
if (isset($submit_attribute) && $submit_attribute != FALSE) {
if (isset($submit_attribute) && $submit_attribute != false) {
$attribute = $submit_attribute;
}
@@ -337,34 +442,29 @@ for ($i = 0; $i <= $num_fields; $i++) {
// (if on_update_current_timestamp is set, then it's TRUE)
if (isset($row['Field'])
&& isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
$attribute = 'ON UPDATE CURRENT_TIMESTAMP';
$attribute = 'on update CURRENT_TIMESTAMP';
}
if ((isset($row['Field'])
&& isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
|| (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
$default_current_timestamp = TRUE;
$default_current_timestamp = true;
} else {
$default_current_timestamp = FALSE;
$default_current_timestamp = false;
}
// Dynamically add ON UPDATE CURRENT_TIMESTAMP to the possible attributes
if (! in_array('ON UPDATE CURRENT_TIMESTAMP', $cfg['AttributeTypes'])) {
$cfg['AttributeTypes'][] = 'ON UPDATE CURRENT_TIMESTAMP';
}
$cnt_attribute_types = count($cfg['AttributeTypes']);
for ($j = 0;$j < $cnt_attribute_types; $j++) {
for ($j = 0; $j < $cnt_attribute_types; $j++) {
$content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
$content_cells[$i][$ci] .= ' selected="selected"';
}
$content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n";
$content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>';
}
$content_cells[$i][$ci] .= '</select>';
$ci++;
// column NULL
$content_cells[$i][$ci] = '<input name="field_null[' . $i . ']"'
. ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
@@ -375,113 +475,67 @@ for ($i = 0; $i <= $num_fields; $i++) {
$content_cells[$i][$ci] .= ' type="checkbox" value="NULL" />';
$ci++;
if (isset($row)
&& !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
$row['Default'] = 'NULL';
}
if ($is_backup) {
$content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_default_orig[' . $i . ']" size="8" value="' . (isset($row) && isset($row['Default']) ? urlencode($row['Default']) : '') . '" />';
} else {
$content_cells[$i][$ci] = "\n";
}
// for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
if ($type_upper == 'TIMESTAMP'
&& $default_current_timestamp
&& isset($row['Default'])) {
$row['Default'] = '';
}
$content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_default[' . $i . ']" size="12" value="' . (isset($row) && isset($row['Default']) ? str_replace('"', '&quot;', $row['Default']) : '') . '" class="textfield" />';
if ($type_upper == 'TIMESTAMP') {
$tmp_display_type = 'block';
} else {
$tmp_display_type = 'none';
$default_current_timestamp = FALSE;
}
$content_cells[$i][$ci] .= '<br /><div id="div_' . $i . '_' . ($ci - $ci_offset) . '" style="white-space: nowrap; display: ' . $tmp_display_type . '"><input id="field_' . $i . '_' . ($ci - $ci_offset) . 'a" type="checkbox" name="field_default_current_timestamp[' . $i . ']"';
if ($default_current_timestamp) {
$content_cells[$i][$ci] .= ' checked="checked" ';
}
$content_cells[$i][$ci] .= ' /><label for="field_' . $i . '_' . ($ci - $ci_offset) . 'a" style="font-size: 70%;">CURRENT_TIMESTAMP</label></div>';
$ci++;
$content_cells[$i][$ci] = '<select name="field_extra[' . $i . ']" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
if (!isset($row) || empty($row['Extra'])) {
$content_cells[$i][$ci] .= "\n";
$content_cells[$i][$ci] .= '<option value="">&nbsp;</option>' . "\n";
$content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
} else {
$content_cells[$i][$ci] .= "\n";
$content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
$content_cells[$i][$ci] .= '<option value="">&nbsp;</option>' . "\n";
}
$content_cells[$i][$ci] .= "\n" . '</select>';
$ci++;
// column indexes
// lem9: See my other comment about removing this 'if'.
if (!$is_backup) {
if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') {
$checked_primary = ' checked="checked"';
} else {
$checked_primary = '';
$content_cells[$i][$ci] = '<select name="field_key[' . $i . ']"'
. ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
$content_cells[$i][$ci] .= '<option value="none_' . $i . '">---</option>';
$content_cells[$i][$ci] .= '<option value="primary_' . $i . '" title="' . $strPrimary . '"';
if (isset($row['Key']) && $row['Key'] == 'PRI') {
$content_cells[$i][$ci] .= ' selected="selected"';
}
if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
$checked_index = ' checked="checked"';
} else {
$checked_index = '';
$content_cells[$i][$ci] .= '>PRIMARY</option>';
$content_cells[$i][$ci] .= '<option value="unique_' . $i . '" title="' . $strUnique . '"';
if (isset($row['Key']) && $row['Key'] == 'UNI') {
$content_cells[$i][$ci] .= ' selected="selected"';
}
if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
$checked_unique = ' checked="checked"';
} else {
$checked_unique = '';
$content_cells[$i][$ci] .= '>UNIQUE</option>';
$content_cells[$i][$ci] .= '<option value="index_' . $i . '" title="' . $strIndex . '"';
if (isset($row['Key']) && $row['Key'] == 'MUL') {
$content_cells[$i][$ci] .= ' selected="selected"';
}
if (empty($checked_primary)
&& empty($checked_index)
&& empty($checked_unique)) {
$checked_none = ' checked="checked"';
} else {
$checked_none = '';
$content_cells[$i][$ci] .= '>INDEX</option>';
$content_cells[$i][$ci] .= '<option value="fulltext_' . $i . '" title="' . $strIdxFulltext . '"';
if (isset($row['Key']) && $row['Key'] == 'FULLTEXT') {
$content_cells[$i][$ci] .= ' selected="selected"';
}
$content_cells[$i][$ci] .= '>FULLTEXT</option>';
if ((isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
$checked_fulltext = ' checked="checked"';
} else {
$checked_fulltext = '';
}
$content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="primary_' . $i . '"' . $checked_primary . ' title="' . $strPrimary . '" />';
$ci++;
$content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="index_' . $i . '"' . $checked_index . ' title="' . $strIndex . '" />';
$ci++;
$content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="unique_' . $i . '"' . $checked_unique . ' title="' . $strUnique . '" />';
$ci++;
$content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="none_' . $i . '"' . $checked_none . ' title="---" />';
$ci++;
$content_cells[$i][$ci] = '<input type="checkbox" name="field_fulltext[' . $i . ']" value="' . $i . '"' . $checked_fulltext . ' title="' . $strIdxFulltext . '" />';
$content_cells[$i][$ci] .= '</select>';
$ci++;
} // end if ($action ==...)
// garvin: comments
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_comments[' . $i . ']" size="12" value="' . (isset($row) && isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '" class="textfield" />';
// column auto_increment
$content_cells[$i][$ci] = '<input name="field_extra[' . $i . ']"'
. ' id="field_' . $i . '_' . ($ci - $ci_offset) . '"';
if (isset($row['Extra']) && $row['Extra'] == 'auto_increment') {
$content_cells[$i][$ci] .= ' checked="checked"';
}
$content_cells[$i][$ci] .= ' type="checkbox" value="AUTO_INCREMENT" />';
$ci++;
// garvin: MIME-types
// column comments
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
. ' type="text" name="field_comments[' . $i . ']" size="12"'
. ' value="' . (isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '"'
. ' class="textfield" />';
$ci++;
// column MIME-types
if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
$content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">' . "\n";
$content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>' . "\n";
$content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[' . $i . ']">';
$content_cells[$i][$ci] .= ' <option value="">&nbsp;</option>';
if (is_array($available_mime['mimetype'])) {
foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
$checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
$checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
$content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
}
}
@@ -489,21 +543,25 @@ for ($i = 0; $i <= $num_fields; $i++) {
$content_cells[$i][$ci] .= '</select>';
$ci++;
$content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">' . "\n";
$content_cells[$i][$ci] .= ' <option value="" title="' . $strNone . '"></option>' . "\n";
$content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[' . $i . ']">';
$content_cells[$i][$ci] .= ' <option value="" title="' . $strNone . '"></option>';
if (is_array($available_mime['transformation'])) {
foreach ($available_mime['transformation'] AS $mimekey => $transform) {
$checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation']) && (preg_match('@' . preg_quote($available_mime['transformation_file'][$mimekey]) . '3?@i', $mime_map[$row['Field']]['transformation'])) ? 'selected ' : '');
$checked = (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation']) && (preg_match('@' . preg_quote($available_mime['transformation_file'][$mimekey]) . '3?@i', $mime_map[$row['Field']]['transformation'])) ? 'selected ' : '');
$tooltip = 'strTransformation_' . strtolower(str_replace('.inc.php', '', $available_mime['transformation_file'][$mimekey]));
$tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', $strMIME_nodescription), 'PMA_transformation_' . $tooltip . '()');
$content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>' . "\n";
$content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>';
}
}
$content_cells[$i][$ci] .= '</select>';
$ci++;
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_transformation_options[' . $i . ']" size="16" value="' . (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '" class="textfield" />';
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
. ' type="text" name="field_transformation_options[' . $i . ']"'
. ' size="16" class="textfield"'
. ' value="' . (isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '"'
. ' />';
//$ci++;
}
} // end for
@@ -519,24 +577,7 @@ document.onkeydown = onKeyDownArrowsHandler;
</script>
<?php
}
// here, the div_x_7 represents a div id which contains
// the default CURRENT TIMESTAMP checkbox and label
// and, field_x_7a represents the checkbox itself
?>
<script type="text/javascript">
// <![CDATA[
function display_field_options(field_type, i) {
if (field_type == 'TIMESTAMP') {
getElement('div_' + i + '_7').style.display = 'block';
} else {
getElement('div_' + i + '_7').style.display = 'none';
getElement('field_' + i + '_7a').checked = false;
}
return true;
}
// ]]>
</script>
<form method="post" action="<?php echo $action; ?>">
<?php
@@ -545,7 +586,7 @@ unset($_form_params);
if (is_array($content_cells) && is_array($header_cells)) {
// last row is for javascript insert
$empty_row = array_pop($content_cells);
//$empty_row = array_pop($content_cells);
echo '<table id="table_columns">';
if ($display_type == 'horizontal') {
@@ -646,21 +687,21 @@ if ($action == 'tbl_create.php') {
<th><?php echo $strCollation ;?>:&nbsp;</th>
</tr>
<tr><td><input type="text" name="comment" size="40" maxlength="80"
value="<?php echo (isset($comment) ? $comment : ''); ?>"
value="<?php echo (isset($_REQUEST['comment']) ? htmlspecialchars($_REQUEST['comment']) : ''); ?>"
class="textfield" />
</td>
<td width="25">&nbsp;</td>
<td>
<?php
echo PMA_StorageEngine::getHtmlSelect('tbl_type', null,
(isset($GLOBALS['tbl_type']) ? $GLOBALS['tbl_type'] : null));
(isset($_REQUEST['tbl_type']) ? $_REQUEST['tbl_type'] : null));
?>
</td>
<td width="25">&nbsp;</td>
<td>
<?php
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation',
null, (isset($tbl_collation) ? $tbl_collation : null), FALSE, 3);
null, (isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null), false, 3);
?>
</td>
</tr>
@@ -673,7 +714,10 @@ if ($action == 'tbl_create.php') {
</tr>
<tr>
<td>
<textarea name="partition_definition" id="partitiondefinition" cols="<?php echo $GLOBALS['cfg']['TextareaCols'];?>" rows="<?php echo $GLOBALS['cfg']['TextareaRows'];?>" dir="<?php echo $GLOBALS['text_dir'];?>"></textarea>
<textarea name="partition_definition" id="partitiondefinition"
cols="<?php echo $GLOBALS['cfg']['TextareaCols'];?>"
rows="<?php echo $GLOBALS['cfg']['TextareaRows'];?>"
dir="<?php echo $GLOBALS['text_dir'];?>"><?php echo (isset($_REQUEST['partition_definition']) ? htmlspecialchars($_REQUEST['partition_definition']) : ''); ?></textarea>
</td>
</tr>
<?php
@@ -686,7 +730,8 @@ if ($action == 'tbl_create.php') {
?>
<fieldset class="tblFooters">
<input type="submit" name="do_save_data" value="<?php echo $strSave; ?>" onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
<input type="submit" name="do_save_data" value="<?php echo $strSave; ?>"
onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
<?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
<?php echo $GLOBALS['strOr']; ?>
<?php echo sprintf($strAddFields, '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>

View File

@@ -27,181 +27,169 @@ $err_url = 'tbl_sql.php?' . PMA_generate_common_url($db, $table);
* The form used to define the field to add has been submitted
*/
$abort = false;
if (isset($submit_num_fields)) {
if (isset($orig_after_field)) {
$after_field = $orig_after_field;
// check number of fields to be created
if (isset($_REQUEST['submit_num_fields'])) {
if (isset($_REQUEST['orig_after_field'])) {
$_REQUEST['after_field'] = $_REQUEST['orig_after_field'];
}
if (isset($orig_field_where)) {
$field_where = $orig_field_where;
if (isset($_REQUEST['orig_field_where'])) {
$_REQUEST['field_where'] = $_REQUEST['orig_field_where'];
}
$num_fields = $orig_num_fields + $added_fields;
$regenerate = TRUE;
} elseif (isset($do_save_data)) {
$num_fields = $_REQUEST['orig_num_fields'] + $_REQUEST['added_fields'];
$regenerate = true;
} elseif (isset($_REQUEST['num_fields']) && intval($_REQUEST['num_fields']) > 0) {
$num_fields = (int) $_REQUEST['num_fields'];
} else {
$num_fields = 1;
}
if (isset($_REQUEST['do_save_data'])) {
$query = '';
$definitions = array();
// Transforms the radio button field_key into 3 arrays
$field_cnt = count($field_name);
$field_cnt = count($_REQUEST['field_name']);
$field_primary = array();
$field_index = array();
$field_unique = array();
for ($i = 0; $i < $field_cnt; ++$i) {
if (isset(${'field_key_' . $i})) {
if (${'field_key_' . $i} == 'primary_' . $i) {
if (isset($_REQUEST['field_key'][$i])
&& strlen($_REQUEST['field_name'][$i])) {
if ($_REQUEST['field_key'][$i] == 'primary_' . $i) {
$field_primary[] = $i;
}
if (${'field_key_' . $i} == 'index_' . $i) {
if ($_REQUEST['field_key'][$i] == 'index_' . $i) {
$field_index[] = $i;
}
if (${'field_key_' . $i} == 'unique_' . $i) {
if ($_REQUEST['field_key'][$i] == 'unique_' . $i) {
$field_unique[] = $i;
}
} // end if
} // end for
// Builds the field creation statement and alters the table
for ($i = 0; $i < $field_cnt; ++$i) {
// '0' is also empty for php :-(
if (empty($field_name[$i]) && $field_name[$i] != '0') {
if (empty($_REQUEST['field_name'][$i]) && $_REQUEST['field_name'][$i] != '0') {
continue;
}
$query .= PMA_Table::generateFieldSpec($field_name[$i], $field_type[$i],
$field_length[$i], $field_attribute[$i],
isset($field_collation[$i]) ? $field_collation[$i] : '',
isset($field_null[$i]) ? $field_null[$i] : 'NOT NULL',
$field_default[$i],
isset($field_default_current_timestamp[$i]), $field_extra[$i],
isset($field_comments[$i]) ? $field_comments[$i] : '',
$field_primary, $i);
$definition = ' ADD ' . PMA_Table::generateFieldSpec(
$_REQUEST['field_name'][$i],
$_REQUEST['field_type'][$i],
$_REQUEST['field_length'][$i],
$_REQUEST['field_attribute'][$i],
isset($_REQUEST['field_collation'][$i])
? $_REQUEST['field_collation'][$i]
: '',
isset($_REQUEST['field_null'][$i])
? $_REQUEST['field_null'][$i]
: 'NOT NULL',
$_REQUEST['field_default_type'][$i],
$_REQUEST['field_default_value'][$i],
$_REQUEST['field_extra'][$i],
isset($_REQUEST['field_comments'][$i])
? $_REQUEST['field_comments'][$i]
: '',
$field_primary,
$i
);
if ($field_where != 'last') {
if ($_REQUEST['field_where'] != 'last') {
// Only the first field can be added somewhere other than at the end
if ($i == 0) {
if ($field_where == 'first') {
$query .= ' FIRST';
if ($_REQUEST['field_where'] == 'first') {
$definition .= ' FIRST';
} else {
$query .= ' AFTER ' . PMA_backquote(urldecode($after_field));
$definition .= ' AFTER ' . PMA_backquote($_REQUEST['after_field']);
}
} else {
$query .= ' AFTER ' . PMA_backquote($field_name[$i-1]);
$definition .= ' AFTER ' . PMA_backquote($_REQUEST['field_name'][$i-1]);
}
}
$query .= ', ADD ';
$definitions[] = $definition;
} // end for
$query = preg_replace('@, ADD $@', '', $query);
// Builds the primary keys statements and updates the table
if (count($field_primary)) {
$fields = array();
foreach ($field_primary as $field_nr) {
$fields[] = $_REQUEST['field_name'][$field_nr];
}
$definitions[] = ' ADD PRIMARY KEY (' . implode(', ', $fields) . ') ';
}
// Builds the indexes statements and updates the table
if (count($field_index)) {
$fields = array();
foreach ($field_index as $field_nr) {
$fields[] = $_REQUEST['field_name'][$field_nr];
}
$definitions[] = ' ADD INDEX (' . implode(', ', $fields) . ') ';
}
// Builds the uniques statements and updates the table
if (count($field_unique)) {
$fields = array();
foreach ($field_unique as $field_nr) {
$fields[] = $_REQUEST['field_name'][$field_nr];
}
$definitions[] = ' ADD UNIQUE (' . implode(', ', $fields) . ') ';
}
// Builds the fulltext statements and updates the table
if (count($field_fulltext)) {
$fields = array();
foreach ($field_fulltext as $field_nr) {
$fields[] = $_REQUEST['field_name'][$field_nr];
}
$definitions[] = ' ADD FULLTEXT (' . implode(', ', $fields) . ') ';
}
// To allow replication, we first select the db to use and then run queries
// on this db.
PMA_DBI_select_db($db) or PMA_mysqlDie(PMA_getError(), 'USE ' . PMA_backquotes($db), '', $err_url);
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD ' . $query;
$error_create = FALSE;
PMA_DBI_try_query($sql_query) or $error_create = TRUE;
if ($error_create == false) {
$sql_query_cpy = $sql_query . ';';
// Builds the primary keys statements and updates the table
$primary = '';
if (isset($field_primary)) {
$primary_cnt = count($field_primary);
for ($i = 0; $i < $primary_cnt; $i++) {
$j = $field_primary[$i];
if (isset($field_name[$j]) && strlen($field_name[$j])) {
$primary .= PMA_backquote($field_name[$j]) . ', ';
}
} // end for
$primary = preg_replace('@, $@', '', $primary);
if (strlen($primary)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD PRIMARY KEY (' . $primary . ');';
$result = PMA_DBI_query($sql_query);
$sql_query_cpy .= "\n" . $sql_query . ';';
}
} // end if
// Builds the indexes statements and updates the table
$index = '';
if (isset($field_index)) {
$index_cnt = count($field_index);
for ($i = 0; $i < $index_cnt; $i++) {
$j = $field_index[$i];
if (isset($field_name[$j]) && strlen($field_name[$j])) {
$index .= PMA_backquote($field_name[$j]) . ', ';
}
} // end for
$index = preg_replace('@, $@', '', $index);
if (strlen($index)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX (' . $index . ')';
$result = PMA_DBI_query($sql_query);
$sql_query_cpy .= "\n" . $sql_query . ';';
}
} // end if
// Builds the uniques statements and updates the table
$unique = '';
if (isset($field_unique)) {
$unique_cnt = count($field_unique);
for ($i = 0; $i < $unique_cnt; $i++) {
$j = $field_unique[$i];
if (isset($field_name[$j]) && strlen($field_name[$j])) {
$unique .= PMA_backquote($field_name[$j]) . ', ';
}
} // end for
$unique = preg_replace('@, $@', '', $unique);
if (strlen($unique)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE (' . $unique . ')';
$result = PMA_DBI_query($sql_query);
$sql_query_cpy .= "\n" . $sql_query . ';';
}
} // end if
// Builds the fulltext statements and updates the table
$fulltext = '';
if (isset($field_fulltext)) {
$fulltext_cnt = count($field_fulltext);
for ($i = 0; $i < $fulltext_cnt; $i++) {
$j = $field_fulltext[$i];
$fulltext .= PMA_backquote($field_name[$j]) . ', ';
} // end for
$fulltext = preg_replace('@, $@', '', $fulltext);
if (strlen($fulltext)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT (' . $fulltext . ')';
$result = PMA_DBI_query($sql_query);
$sql_query_cpy .= "\n" . $sql_query . ';';
}
} // end if
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ' . implode(', ', $definitions);
$result = PMA_DBI_try_query($sql_query);
if ($result === true) {
// garvin: If comments were sent, enable relation stuff
require_once './libraries/relation.lib.php';
require_once './libraries/transformations.lib.php';
$cfgRelation = PMA_getRelationsParam();
// garvin: Update comment table for mime types [MIME]
if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
foreach ($field_mimetype AS $fieldindex => $mimetype) {
if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
if (isset($_REQUEST['field_mimetype'])
&& is_array($_REQUEST['field_mimetype'])
&& $cfg['BrowseMIME']) {
foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
if (isset($_REQUEST['field_name'][$fieldindex])
&& strlen($_REQUEST['field_name'][$fieldindex])) {
PMA_setMIME($db, $table,
$_REQUEST['field_name'][$fieldindex],
$mimetype,
$_REQUEST['field_transformation'][$fieldindex],
$_REQUEST['field_transformation_options'][$fieldindex]);
}
}
}
// Go back to the structure sub-page
$sql_query = $sql_query_cpy;
unset($sql_query_cpy);
$message = PMA_Message::success('strTableAlteredSuccessfully');
$message->addParam($table);
$active_page = 'tbl_structure.php';
require './tbl_structure.php';
} else {
PMA_mysqlDie('', '', '', $err_url, FALSE);
PMA_mysqlDie('', '', '', $err_url, false);
// garvin: An error happened while inserting/updating a table definition.
// to prevent total loss of that data, we embed the form once again.
// The variable $regenerate will be used to restore data in libraries/tbl_properties.inc.php
$num_fields = $orig_num_fields;
if (isset($orig_after_field)) {
$after_field = $orig_after_field;
$num_fields = $_REQUEST['orig_num_fields'];
if (isset($_REQUEST['orig_after_field'])) {
$_REQUEST['after_field'] = $_REQUEST['orig_after_field'];
}
if (isset($orig_field_where)) {
$field_where = $orig_field_where;
if (isset($_REQUEST['orig_field_where'])) {
$_REQUEST['field_where'] = $_REQUEST['orig_field_where'];
}
$regenerate = true;
}
@@ -210,7 +198,7 @@ if (isset($submit_num_fields)) {
/**
* Displays the form used to define the new field
*/
if ($abort == FALSE) {
if ($abort == false) {
/**
* Gets tables informations
*/
@@ -228,7 +216,6 @@ if ($abort == FALSE) {
require_once './libraries/tbl_properties.inc.php';
// Diplays the footer
echo "\n";
require_once './libraries/footer.inc.php';
}

View File

@@ -26,13 +26,8 @@ PMA_checkParameters(array('db', 'table'));
*/
require_once './libraries/tbl_common.php';
require_once './libraries/tbl_info.inc.php';
/**
* Displays top menu links
*/
$active_page = 'tbl_structure.php';
// I don't see the need to display the links here, they will be displayed later
//require './libraries/tbl_links.inc.php';
$active_page = 'tbl_structure.php';
/**
* Defines the url to return to in case of error in a sql statement
@@ -44,47 +39,65 @@ $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
* Modifications have been submitted -> updates the table
*/
$abort = false;
if (isset($do_save_data)) {
$field_cnt = count($field_orig);
if (isset($_REQUEST['do_save_data'])) {
var_dump($_POST);
$field_cnt = count($_REQUEST['field_orig']);
$key_fields = array();
$changes = array();
for ($i = 0; $i < $field_cnt; $i++) {
// to "&quot;" in tbl_sql.php
$field_orig[$i] = urldecode($field_orig[$i]);
if (strcmp(str_replace('"', '&quot;', $field_orig[$i]), $field_name[$i]) == 0) {
$field_name[$i] = $field_orig[$i];
}
$field_default_orig[$i] = urldecode($field_default_orig[$i]);
if (strcmp(str_replace('"', '&quot;', $field_default_orig[$i]), $field_default[$i]) == 0) {
$field_default[$i] = $field_default_orig[$i];
}
$field_length_orig[$i] = urldecode($field_length_orig[$i]);
if (strcmp(str_replace('"', '&quot;', $field_length_orig[$i]), $field_length[$i]) == 0) {
$field_length[$i] = $field_length_orig[$i];
}
if (!isset($query)) {
$query = '';
} else {
$query .= ', CHANGE ';
}
$query .= PMA_Table::generateAlter($field_orig[$i], $field_name[$i],
$field_type[$i], $field_length[$i], $field_attribute[$i],
isset($field_collation[$i]) ? $field_collation[$i] : '',
isset($field_null[$i]) ? $field_null[$i] : 'NOT NULL',
$field_default[$i],
isset($field_default_current_timestamp[$i]), $field_extra[$i],
isset($field_comments[$i]) ? $field_comments[$i] : '',
$field_default_orig[$i]);
$changes[] = 'CHANGE ' . PMA_Table::generateAlter(
$_REQUEST['field_orig'][$i],
$_REQUEST['field_name'][$i],
$_REQUEST['field_type'][$i],
$_REQUEST['field_length'][$i],
$_REQUEST['field_attribute'][$i],
isset($_REQUEST['field_collation'][$i])
? $_REQUEST['field_collation'][$i]
: '',
isset($_REQUEST['field_null'][$i])
? $_REQUEST['field_null'][$i]
: 'NOT NULL',
$_REQUEST['field_default_type'][$i],
$_REQUEST['field_default_value'][$i],
$_REQUEST['field_extra'][$i],
isset($_REQUEST['field_comments'][$i])
? $_REQUEST['field_comments'][$i]
: '',
$key_fields,
$i,
$_REQUEST['field_default_orig'][$i]
);
} // end for
// Builds the primary keys statements and updates the table
$key_query = '';
/**
* this is a little bit more complex
*
* @todo if someone selects A_I when altering a column we need to check:
* - no other column with A_I
* - the column has an index, if not create one
*
if (count($key_fields)) {
$fields = array();
foreach ($key_fields as $each_field) {
if (isset($_REQUEST['field_name'][$each_field]) && strlen($_REQUEST['field_name'][$each_field])) {
$fields[] = PMA_backquote($_REQUEST['field_name'][$each_field]);
}
} // end for
$key_query = ', ADD KEY (' . implode(', ', $fields) . ') ';
}
*/
// To allow replication, we first select the db to use and then run queries
// on this db.
PMA_DBI_select_db($db) or PMA_mysqlDie(PMA_DBI_getError(), 'USE ' . PMA_backquote($db) . ';', '', $err_url);
// Optimization fix - 2 May 2001 - Robbat2
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE ' . $query;
$error_create = FALSE;
$result = PMA_DBI_try_query($sql_query) or $error_create = TRUE;
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ' . implode(', ', $changes) . $key_query;
$result = PMA_DBI_try_query($sql_query);
if ($error_create == FALSE) {
if ($result !== false) {
$message = PMA_Message::success('strTableAlteredSuccessfully');
$message->addParam($table);
$btnDrop = 'Fake';
@@ -93,51 +106,27 @@ if (isset($do_save_data)) {
require_once './libraries/relation.lib.php';
require_once './libraries/transformations.lib.php';
$cfgRelation = PMA_getRelationsParam();
// updaet field names in relation
if (isset($_REQUEST['field_orig']) && is_array($_REQUEST['field_orig'])) {
foreach ($_REQUEST['field_orig'] as $fieldindex => $fieldcontent) {
if ($_REQUEST['field_name'][$fieldindex] != $fieldcontent) {
PMA_REL_renameField($db, $table, $fieldcontent,
$_REQUEST['field_name'][$fieldindex]);
}
}
}
// garvin: Rename relations&display fields, if altered.
if (($cfgRelation['displaywork'] || $cfgRelation['relwork']) && isset($field_orig) && is_array($field_orig)) {
foreach ($field_orig AS $fieldindex => $fieldcontent) {
if ($field_name[$fieldindex] != $fieldcontent) {
if ($cfgRelation['displaywork']) {
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
. ' SET display_field = \'' . PMA_sqlAddslashes($field_name[$fieldindex]) . '\''
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND display_field = \'' . PMA_sqlAddslashes($fieldcontent) . '\'';
$tb_rs = PMA_query_as_cu($table_query);
unset($table_query);
unset($tb_rs);
}
if ($cfgRelation['relwork']) {
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
. ' SET master_field = \'' . PMA_sqlAddslashes($field_name[$fieldindex]) . '\''
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND master_field = \'' . PMA_sqlAddslashes($fieldcontent) . '\'';
$tb_rs = PMA_query_as_cu($table_query);
unset($table_query);
unset($tb_rs);
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
. ' SET foreign_field = \'' . PMA_sqlAddslashes($field_name[$fieldindex]) . '\''
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND foreign_field = \'' . PMA_sqlAddslashes($fieldcontent) . '\'';
$tb_rs = PMA_query_as_cu($table_query);
unset($table_query);
unset($tb_rs);
} // end if relwork
} // end if fieldname has changed
} // end while check fieldnames
} // end if relations/display has to be changed
// garvin: Update comment table for mime types [MIME]
if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
foreach ($field_mimetype AS $fieldindex => $mimetype) {
if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
// update mime types
if (isset($_REQUEST['field_mimetype'])
&& is_array($_REQUEST['field_mimetype'])
&& $cfg['BrowseMIME']) {
foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
if (isset($_REQUEST['field_name'][$fieldindex])
&& strlen($_REQUEST['field_name'][$fieldindex])) {
PMA_setMIME($db, $table, $_REQUEST['field_name'][$fieldindex],
$mimetype,
$_REQUEST['field_transformation'][$fieldindex],
$_REQUEST['field_transformation_options'][$fieldindex]);
}
}
}
@@ -145,12 +134,12 @@ if (isset($do_save_data)) {
$active_page = 'tbl_structure.php';
require './tbl_structure.php';
} else {
PMA_mysqlDie('', '', '', $err_url, FALSE);
PMA_mysqlDie('', '', '', $err_url, false);
// garvin: An error happened while inserting/updating a table definition.
// to prevent total loss of that data, we embed the form once again.
// The variable $regenerate will be used to restore data in libraries/tbl_properties.inc.php
if (isset($orig_field)) {
$field = $orig_field;
if (isset($_REQUEST['orig_field'])) {
$_REQUEST['field'] = $_REQUEST['orig_field'];
}
$regenerate = true;
@@ -159,11 +148,13 @@ if (isset($do_save_data)) {
/**
* No modifications yet required -> displays the table fields
*
* $selected comes from multi_submits.inc.php
*/
if ($abort == FALSE) {
if (!isset($selected)) {
if ($abort == false) {
if (! isset($selected)) {
PMA_checkParameters(array('field'));
$selected[] = $field;
$selected[] = $_REQUEST['field'];
$selected_cnt = 1;
} else { // from a multiple submit
$selected_cnt = count($selected);
@@ -173,12 +164,8 @@ if ($abort == FALSE) {
* @todo optimize in case of multiple fields to modify
*/
for ($i = 0; $i < $selected_cnt; $i++) {
if (!empty($submit_mult)) {
$field = PMA_sqlAddslashes(urldecode($selected[$i]), TRUE);
} else {
$field = PMA_sqlAddslashes($selected[$i], TRUE);
}
$result = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ' LIKE \'' . $field . '\';');
$_REQUEST['field'] = PMA_sqlAddslashes($selected[$i], true);
$result = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ' LIKE \'' . $_REQUEST['field'] . '\';');
$fields_meta[] = PMA_DBI_fetch_assoc($result);
PMA_DBI_free_result($result);
}

View File

@@ -63,6 +63,16 @@ if (! strlen($table)) {
$err_url = 'tbl_create.php?' . PMA_generate_common_url($db, $table);
// check number of fields to be created
if (isset($_REQUEST['submit_num_fields'])) {
$regenerate = true; // for libraries/tbl_properties.inc.php
$num_fields = $_REQUEST['orig_num_fields'] + $_REQUEST['added_fields'];
} elseif (isset($_REQUEST['num_fields']) && intval($_REQUEST['num_fields']) > 0) {
$num_fields = (int) $_REQUEST['num_fields'];
} else {
$num_fields = 2;
}
/**
* Selects the database to work with
*/
@@ -75,35 +85,47 @@ if (isset($_REQUEST['do_save_data'])) {
$sql_query = '';
// Transforms the radio button field_key into 3 arrays
$field_cnt = count($field_name);
$field_cnt = count($_REQUEST['field_name']);
for ($i = 0; $i < $field_cnt; ++$i) {
if (isset(${'field_key_' . $i})) {
if (${'field_key_' . $i} == 'primary_' . $i) {
if (isset($_REQUEST['field_key'][$i])) {
if ($_REQUEST['field_key'][$i] == 'primary_' . $i) {
$field_primary[] = $i;
}
if (${'field_key_' . $i} == 'index_' . $i) {
if ($_REQUEST['field_key'][$i] == 'index_' . $i) {
$field_index[] = $i;
}
if (${'field_key_' . $i} == 'unique_' . $i) {
if ($_REQUEST['field_key'][$i] == 'unique_' . $i) {
$field_unique[] = $i;
}
} // end if
} // end for
// Builds the fields creation statements
for ($i = 0; $i < $field_cnt; $i++) {
// '0' is also empty for php :-(
if (empty($field_name[$i]) && $field_name[$i] != '0') {
if (empty($_REQUEST['field_name'][$i]) && $_REQUEST['field_name'][$i] != '0') {
continue;
}
$query = PMA_Table::generateFieldSpec($field_name[$i], $field_type[$i],
$field_length[$i], $field_attribute[$i],
isset($field_collation[$i]) ? $field_collation[$i] : '',
isset($field_null[$i]) ? $field_null[$i] : 'NOT NULL',
$field_default[$i],
isset($field_default_current_timestamp[$i]), $field_extra[$i],
isset($field_comments[$i]) ? $field_comments[$i] : '',
$field_primary, $i);
$query = PMA_Table::generateFieldSpec(
$_REQUEST['field_name'][$i],
$_REQUEST['field_type'][$i],
$_REQUEST['field_length'][$i],
$_REQUEST['field_attribute'][$i],
isset($_REQUEST['field_collation'][$i])
? $_REQUEST['field_collation'][$i]
: '',
isset($_REQUEST['field_null'][$i])
? $_REQUEST['field_null'][$i]
: 'NOT NULL',
$_REQUEST['field_default_type'][$i],
$_REQUEST['field_default_value'][$i],
$_REQUEST['field_extra'][$i],
isset($_REQUEST['field_comments'][$i])
? $_REQUEST['field_comments'][$i]
: '',
$field_primary,
$i);
$query .= ', ';
$sql_query .= $query;
@@ -116,8 +138,8 @@ if (isset($_REQUEST['do_save_data'])) {
$primary_cnt = (isset($field_primary) ? count($field_primary) : 0);
for ($i = 0; $i < $primary_cnt; $i++) {
$j = $field_primary[$i];
if (isset($field_name[$j]) && strlen($field_name[$j])) {
$primary .= PMA_backquote($field_name[$j]) . ', ';
if (isset($_REQUEST['field_name'][$j]) && strlen($_REQUEST['field_name'][$j])) {
$primary .= PMA_backquote($_REQUEST['field_name'][$j]) . ', ';
}
} // end for
unset($primary_cnt);
@@ -132,8 +154,8 @@ if (isset($_REQUEST['do_save_data'])) {
$index_cnt = (isset($field_index) ? count($field_index) : 0);
for ($i = 0;$i < $index_cnt; $i++) {
$j = $field_index[$i];
if (isset($field_name[$j]) && strlen($field_name[$j])) {
$index .= PMA_backquote($field_name[$j]) . ', ';
if (isset($_REQUEST['field_name'][$j]) && strlen($_REQUEST['field_name'][$j])) {
$index .= PMA_backquote($_REQUEST['field_name'][$j]) . ', ';
}
} // end for
unset($index_cnt);
@@ -148,8 +170,8 @@ if (isset($_REQUEST['do_save_data'])) {
$unique_cnt = (isset($field_unique) ? count($field_unique) : 0);
for ($i = 0; $i < $unique_cnt; $i++) {
$j = $field_unique[$i];
if (isset($field_name[$j]) && strlen($field_name[$j])) {
$unique .= PMA_backquote($field_name[$j]) . ', ';
if (isset($_REQUEST['field_name'][$j]) && strlen($_REQUEST['field_name'][$j])) {
$unique .= PMA_backquote($_REQUEST['field_name'][$j]) . ', ';
}
} // end for
unset($unique_cnt);
@@ -164,8 +186,8 @@ if (isset($_REQUEST['do_save_data'])) {
$fulltext_cnt = (isset($field_fulltext) ? count($field_fulltext) : 0);
for ($i = 0; $i < $fulltext_cnt; $i++) {
$j = $field_fulltext[$i];
if (isset($field_name[$j]) && strlen($field_name[$j])) {
$fulltext .= PMA_backquote($field_name[$j]) . ', ';
if (isset($_REQUEST['field_name'][$j]) && strlen($_REQUEST['field_name'][$j])) {
$fulltext .= PMA_backquote($_REQUEST['field_name'][$j]) . ', ';
}
} // end for
@@ -180,17 +202,17 @@ if (isset($_REQUEST['do_save_data'])) {
. ' (' . $sql_query . ')';
// Adds table type, character set, comments and partition definition
if (!empty($tbl_type) && ($tbl_type != 'Default')) {
$sql_query .= ' ENGINE = ' . $tbl_type;
if (!empty($_REQUEST['tbl_type']) && ($_REQUEST['tbl_type'] != 'Default')) {
$sql_query .= ' ENGINE = ' . $_REQUEST['tbl_type'];
}
if (!empty($tbl_collation)) {
$sql_query .= PMA_generateCharsetQueryPart($tbl_collation);
if (!empty($_REQUEST['tbl_collation'])) {
$sql_query .= PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
}
if (!empty($comment)) {
$sql_query .= ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
if (!empty($_REQUEST['comment'])) {
$sql_query .= ' COMMENT = \'' . PMA_sqlAddslashes($_REQUEST['comment']) . '\'';
}
if (!empty($partition_definition)) {
$sql_query .= ' ' . PMA_sqlAddslashes($partition_definition);
if (!empty($_REQUEST['partition_definition'])) {
$sql_query .= ' ' . PMA_sqlAddslashes($_REQUEST['partition_definition']);
}
// Executes the query
@@ -202,17 +224,16 @@ if (isset($_REQUEST['do_save_data'])) {
require_once './libraries/relation.lib.php';
require_once './libraries/transformations.lib.php';
$cfgRelation = PMA_getRelationsParam();
// garvin: Update comment table for mime types [MIME]
if (isset($field_mimetype) && is_array($field_mimetype)
&& $cfgRelation['commwork'] && $cfgRelation['mimework']
if (isset($_REQUEST['field_mimetype'])
&& is_array($_REQUEST['field_mimetype'])
&& $cfg['BrowseMIME']) {
foreach ($field_mimetype as $fieldindex => $mimetype) {
if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype,
$field_transformation[$fieldindex],
$field_transformation_options[$fieldindex]);
foreach ($_REQUEST['field_mimetype'] as $fieldindex => $mimetype) {
if (isset($_REQUEST['field_name'][$fieldindex])
&& strlen($_REQUEST['field_name'][$fieldindex])) {
PMA_setMIME($db, $table, $_REQUEST['field_name'][$fieldindex], $mimetype,
$_REQUEST['field_transformation'][$fieldindex],
$_REQUEST['field_transformation_options'][$fieldindex]);
}
}
}
@@ -235,23 +256,13 @@ if (isset($_REQUEST['do_save_data'])) {
// garvin: An error happened while inserting/updating a table definition.
// to prevent total loss of that data, we embed the form once again.
// The variable $regenerate will be used to restore data in libraries/tbl_properties.inc.php
$num_fields = $orig_num_fields;
$num_fields = $_REQUEST['orig_num_fields'];
}
} // end do create table
/**
* Displays the form used to define the structure of the table
*/
// check number of fields to be created
if (isset($_REQUEST['submit_num_fields'])) {
$regenerate = true; // for libraries/tbl_properties.inc.php
$num_fields = $_REQUEST['orig_num_fields'] + $_REQUEST['added_fields'];
} elseif (isset($_REQUEST['num_fields']) && intval($_REQUEST['num_fields']) > 0) {
$num_fields = (int) $_REQUEST['num_fields'];
} else {
$num_fields = 1;
}
$action = 'tbl_create.php';
require './libraries/tbl_properties.inc.php';
// Displays the footer

View File

@@ -294,7 +294,7 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
// MySQL 4.1.2+ TIMESTAMP options
// (if on_update_current_timestamp is set, then it's TRUE)
if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
$attribute = 'ON UPDATE CURRENT_TIMESTAMP';
$attribute = 'on update CURRENT_TIMESTAMP';
}
// here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the