Do not waste the data for table-field creation, if MySQL shows an error.
Instead, give the user the opportunity to fix the errors and display the form again.
This commit is contained in:
@@ -14,9 +14,9 @@ $Source$
|
|||||||
* sql.php3: Fixed another occurence of addslashes() where it no longer
|
* sql.php3: Fixed another occurence of addslashes() where it no longer
|
||||||
belongs.
|
belongs.
|
||||||
* tbl_addfield.php3, tbl_alter.php3, tbl_create.php3,
|
* tbl_addfield.php3, tbl_alter.php3, tbl_create.php3,
|
||||||
tbl_properties.inc.php3: Goodie for you all - when creating/altering/
|
tbl_properties.inc.php3, libraries/common.lib.php3: Goodie for you all
|
||||||
adding table fields you can now change the wrong form input, instead
|
- when creating/altering/adding table fields you can now change the
|
||||||
of losing all your data. Have fun. :-)
|
wrong form input, instead of losing all your data. Have fun. :-)
|
||||||
* tbl_dump.php3, tbl_properties_export.php3, css/phpmyadmin.css.php3,
|
* tbl_dump.php3, tbl_properties_export.php3, css/phpmyadmin.css.php3,
|
||||||
lang/*:
|
lang/*:
|
||||||
Added new table export format by Michal Cihar. db_details_export.php3
|
Added new table export format by Michal Cihar. db_details_export.php3
|
||||||
|
@@ -399,13 +399,15 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
* @param string the sql query that failed
|
* @param string the sql query that failed
|
||||||
* @param boolean whether to show a "modify" link or not
|
* @param boolean whether to show a "modify" link or not
|
||||||
* @param string the "back" link url (full path is not required)
|
* @param string the "back" link url (full path is not required)
|
||||||
|
* @param boolean EXIT the page?
|
||||||
*
|
*
|
||||||
* @global array the configuration array
|
* @global array the configuration array
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function PMA_mysqlDie($error_message = '', $the_query = '',
|
function PMA_mysqlDie($error_message = '', $the_query = '',
|
||||||
$is_modify_link = TRUE, $back_url = '')
|
$is_modify_link = TRUE, $back_url = '',
|
||||||
|
$exit = TRUE)
|
||||||
{
|
{
|
||||||
global $cfg;
|
global $cfg;
|
||||||
|
|
||||||
@@ -466,13 +468,15 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
. '</pre>' . "\n";
|
. '</pre>' . "\n";
|
||||||
|
|
||||||
|
|
||||||
if (!empty($back_url)) {
|
if (!empty($back_url) && $exit) {
|
||||||
echo '<a href="' . $back_url . '">' . $GLOBALS['strBack'] . '</a>';
|
echo '<a href="' . $back_url . '">' . $GLOBALS['strBack'] . '</a>';
|
||||||
}
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
include('./footer.inc.php3');
|
if ($exit) {
|
||||||
exit();
|
include('./footer.inc.php3');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
} // end of the 'PMA_mysqlDie()' function
|
} // end of the 'PMA_mysqlDie()' function
|
||||||
|
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@ $err_url = 'tbl_properties.php3?' . PMA_generate_common_url($db, $table);
|
|||||||
/**
|
/**
|
||||||
* The form used to define the field to add has been submitted
|
* The form used to define the field to add has been submitted
|
||||||
*/
|
*/
|
||||||
|
$abort = false;
|
||||||
if (isset($submit)) {
|
if (isset($submit)) {
|
||||||
$query = '';
|
$query = '';
|
||||||
|
|
||||||
@@ -101,114 +102,129 @@ if (isset($submit)) {
|
|||||||
$sql_query = 'USE ' . PMA_backquote($db);
|
$sql_query = 'USE ' . PMA_backquote($db);
|
||||||
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
||||||
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD ' . $query;
|
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD ' . $query;
|
||||||
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
$error_create = false;
|
||||||
$sql_query_cpy = $sql_query . ';';
|
$result = PMA_mysql_query($sql_query) or $error_create = true;
|
||||||
|
|
||||||
// Builds the primary keys statements and updates the table
|
if ($error_create == false) {
|
||||||
$primary = '';
|
|
||||||
if (isset($field_primary)) {
|
$sql_query_cpy = $sql_query . ';';
|
||||||
$primary_cnt = count($field_primary);
|
|
||||||
for ($i = 0; $i < $primary_cnt; $i++) {
|
// Builds the primary keys statements and updates the table
|
||||||
$j = $field_primary[$i];
|
$primary = '';
|
||||||
if (!empty($field_name[$j])) {
|
if (isset($field_primary)) {
|
||||||
$primary .= PMA_backquote($field_name[$j]) . ', ';
|
$primary_cnt = count($field_primary);
|
||||||
|
for ($i = 0; $i < $primary_cnt; $i++) {
|
||||||
|
$j = $field_primary[$i];
|
||||||
|
if (!empty($field_name[$j])) {
|
||||||
|
$primary .= PMA_backquote($field_name[$j]) . ', ';
|
||||||
|
}
|
||||||
|
} // end for
|
||||||
|
$primary = ereg_replace(', $', '', $primary);
|
||||||
|
if (!empty($primary)) {
|
||||||
|
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD PRIMARY KEY (' . $primary . ')';
|
||||||
|
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
||||||
|
$sql_query_cpy .= "\n" . $sql_query . ';';
|
||||||
}
|
}
|
||||||
} // end for
|
} // end if
|
||||||
$primary = ereg_replace(', $', '', $primary);
|
|
||||||
if (!empty($primary)) {
|
// Builds the indexes statements and updates the table
|
||||||
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD PRIMARY KEY (' . $primary . ')';
|
$index = '';
|
||||||
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
if (isset($field_index)) {
|
||||||
$sql_query_cpy .= "\n" . $sql_query . ';';
|
$index_cnt = count($field_index);
|
||||||
}
|
for ($i = 0; $i < $index_cnt; $i++) {
|
||||||
} // end if
|
$j = $field_index[$i];
|
||||||
|
if (!empty($field_name[$j])) {
|
||||||
// Builds the indexes statements and updates the table
|
$index .= PMA_backquote($field_name[$j]) . ', ';
|
||||||
$index = '';
|
}
|
||||||
if (isset($field_index)) {
|
} // end for
|
||||||
$index_cnt = count($field_index);
|
$index = ereg_replace(', $', '', $index);
|
||||||
for ($i = 0; $i < $index_cnt; $i++) {
|
if (!empty($index)) {
|
||||||
$j = $field_index[$i];
|
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX (' . $index . ')';
|
||||||
if (!empty($field_name[$j])) {
|
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
||||||
$index .= PMA_backquote($field_name[$j]) . ', ';
|
$sql_query_cpy .= "\n" . $sql_query . ';';
|
||||||
}
|
}
|
||||||
} // end for
|
} // end if
|
||||||
$index = ereg_replace(', $', '', $index);
|
|
||||||
if (!empty($index)) {
|
// Builds the uniques statements and updates the table
|
||||||
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX (' . $index . ')';
|
$unique = '';
|
||||||
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
if (isset($field_unique)) {
|
||||||
$sql_query_cpy .= "\n" . $sql_query . ';';
|
$unique_cnt = count($field_unique);
|
||||||
}
|
for ($i = 0; $i < $unique_cnt; $i++) {
|
||||||
} // end if
|
$j = $field_unique[$i];
|
||||||
|
if (!empty($field_name[$j])) {
|
||||||
// Builds the uniques statements and updates the table
|
$unique .= PMA_backquote($field_name[$j]) . ', ';
|
||||||
$unique = '';
|
}
|
||||||
if (isset($field_unique)) {
|
} // end for
|
||||||
$unique_cnt = count($field_unique);
|
$unique = ereg_replace(', $', '', $unique);
|
||||||
for ($i = 0; $i < $unique_cnt; $i++) {
|
if (!empty($unique)) {
|
||||||
$j = $field_unique[$i];
|
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE (' . $unique . ')';
|
||||||
if (!empty($field_name[$j])) {
|
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
||||||
$unique .= PMA_backquote($field_name[$j]) . ', ';
|
$sql_query_cpy .= "\n" . $sql_query . ';';
|
||||||
|
}
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
|
||||||
|
// Builds the fulltext statements and updates the table
|
||||||
|
$fulltext = '';
|
||||||
|
if (PMA_MYSQL_INT_VERSION >= 32323 && 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 = ereg_replace(', $', '', $fulltext);
|
||||||
|
if (!empty($fulltext)) {
|
||||||
|
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT (' . $fulltext . ')';
|
||||||
|
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
||||||
|
$sql_query_cpy .= "\n" . $sql_query . ';';
|
||||||
|
}
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
// garvin: If comments were sent, enable relation stuff
|
||||||
|
require('./libraries/relation.lib.php3');
|
||||||
|
require('./libraries/transformations.lib.php3');
|
||||||
|
|
||||||
|
$cfgRelation = PMA_getRelationsParam();
|
||||||
|
|
||||||
|
// garvin: Update comment table, if a comment was set.
|
||||||
|
if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) {
|
||||||
|
@reset($field_comments);
|
||||||
|
while(list($fieldindex, $fieldcomment) = each($field_comments)) {
|
||||||
|
PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment);
|
||||||
}
|
}
|
||||||
} // end for
|
|
||||||
$unique = ereg_replace(', $', '', $unique);
|
|
||||||
if (!empty($unique)) {
|
|
||||||
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE (' . $unique . ')';
|
|
||||||
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
|
||||||
$sql_query_cpy .= "\n" . $sql_query . ';';
|
|
||||||
}
|
}
|
||||||
} // end if
|
|
||||||
|
// garvin: Update comment table for mime types [MIME]
|
||||||
|
if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
|
||||||
// Builds the fulltext statements and updates the table
|
@reset($field_mimetype);
|
||||||
$fulltext = '';
|
while(list($fieldindex, $mimetype) = each($field_mimetype)) {
|
||||||
if (PMA_MYSQL_INT_VERSION >= 32323 && isset($field_fulltext)) {
|
PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
|
||||||
$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 = ereg_replace(', $', '', $fulltext);
|
|
||||||
if (!empty($fulltext)) {
|
|
||||||
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT (' . $fulltext . ')';
|
|
||||||
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
|
||||||
$sql_query_cpy .= "\n" . $sql_query . ';';
|
|
||||||
}
|
}
|
||||||
} // end if
|
|
||||||
|
// Go back to the structure sub-page
|
||||||
// garvin: If comments were sent, enable relation stuff
|
$sql_query = $sql_query_cpy;
|
||||||
require('./libraries/relation.lib.php3');
|
unset($sql_query_cpy);
|
||||||
require('./libraries/transformations.lib.php3');
|
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
|
||||||
|
include('./tbl_properties_structure.php3');
|
||||||
$cfgRelation = PMA_getRelationsParam();
|
exit();
|
||||||
|
} else {
|
||||||
// garvin: Update comment table, if a comment was set.
|
PMA_mysqlDie('', '', '', $err_url, FALSE);
|
||||||
if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) {
|
// garvin: An error happened while inserting/updating a table definition.
|
||||||
@reset($field_comments);
|
// to prevent total loss of that data, we embed the form once again.
|
||||||
while(list($fieldindex, $fieldcomment) = each($field_comments)) {
|
// The variable $regenerate will be used to restore data in tbl_properties.inc.php3
|
||||||
PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment);
|
$num_fields = $orig_num_fields;
|
||||||
|
if (isset($orig_after_field)) {
|
||||||
|
$after_field = $orig_after_field;
|
||||||
}
|
}
|
||||||
|
$regenerate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// garvin: Update comment table for mime types [MIME]
|
|
||||||
if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
|
|
||||||
@reset($field_mimetype);
|
|
||||||
while(list($fieldindex, $mimetype) = each($field_mimetype)) {
|
|
||||||
PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Go back to the structure sub-page
|
|
||||||
$sql_query = $sql_query_cpy;
|
|
||||||
unset($sql_query_cpy);
|
|
||||||
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
|
|
||||||
include('./tbl_properties_structure.php3');
|
|
||||||
exit();
|
|
||||||
} // end do alter table
|
} // end do alter table
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the form used to define the new field
|
* Displays the form used to define the new field
|
||||||
*/
|
*/
|
||||||
else{
|
if ($abort == FALSE) {
|
||||||
$action = 'tbl_addfield.php3';
|
$action = 'tbl_addfield.php3';
|
||||||
include('./tbl_properties.inc.php3');
|
include('./tbl_properties.inc.php3');
|
||||||
|
|
||||||
|
@@ -22,6 +22,7 @@ $err_url = 'tbl_properties_structure.php3?' . PMA_generate_common_url($db, $tabl
|
|||||||
/**
|
/**
|
||||||
* Modifications have been submitted -> updates the table
|
* Modifications have been submitted -> updates the table
|
||||||
*/
|
*/
|
||||||
|
$abort = false;
|
||||||
if (isset($submit)) {
|
if (isset($submit)) {
|
||||||
$field_cnt = count($field_orig);
|
$field_cnt = count($field_orig);
|
||||||
for ($i = 0; $i < $field_cnt; $i++) {
|
for ($i = 0; $i < $field_cnt; $i++) {
|
||||||
@@ -78,41 +79,54 @@ if (isset($submit)) {
|
|||||||
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
||||||
// Optimization fix - 2 May 2001 - Robbat2
|
// Optimization fix - 2 May 2001 - Robbat2
|
||||||
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE ' . $query;
|
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE ' . $query;
|
||||||
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
$error_create = false;
|
||||||
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
|
$result = PMA_mysql_query($sql_query) or $error_create = true;
|
||||||
$btnDrop = 'Fake';
|
|
||||||
|
|
||||||
// garvin: If comments were sent, enable relation stuff
|
if ($error_create == false) {
|
||||||
require('./libraries/relation.lib.php3');
|
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
|
||||||
require('./libraries/transformations.lib.php3');
|
$btnDrop = 'Fake';
|
||||||
|
|
||||||
$cfgRelation = PMA_getRelationsParam();
|
|
||||||
|
|
||||||
// garvin: Update comment table, if a comment was set.
|
// garvin: If comments were sent, enable relation stuff
|
||||||
if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) {
|
require('./libraries/relation.lib.php3');
|
||||||
@reset($field_comments);
|
require('./libraries/transformations.lib.php3');
|
||||||
while(list($fieldindex, $fieldcomment) = each($field_comments)) {
|
|
||||||
PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, $field_orig[$fieldindex]);
|
$cfgRelation = PMA_getRelationsParam();
|
||||||
|
|
||||||
|
// garvin: Update comment table, if a comment was set.
|
||||||
|
if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) {
|
||||||
|
@reset($field_comments);
|
||||||
|
while(list($fieldindex, $fieldcomment) = each($field_comments)) {
|
||||||
|
PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, $field_orig[$fieldindex]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// garvin: Update comment table for mime types [MIME]
|
||||||
// garvin: Update comment table for mime types [MIME]
|
if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
|
||||||
if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
|
@reset($field_mimetype);
|
||||||
@reset($field_mimetype);
|
while(list($fieldindex, $mimetype) = each($field_mimetype)) {
|
||||||
while(list($fieldindex, $mimetype) = each($field_mimetype)) {
|
PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
|
||||||
PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
include('./tbl_properties_structure.php3');
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
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 tbl_properties.inc.php3
|
||||||
|
if (isset($orig_field)) {
|
||||||
|
$field = $orig_field;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
include('./tbl_properties_structure.php3');
|
$regenerate = true;
|
||||||
exit();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* No modifications yet required -> displays the table fields
|
* No modifications yet required -> displays the table fields
|
||||||
*/
|
*/
|
||||||
else {
|
if ($abort == FALSE) {
|
||||||
if (!isset($selected)) {
|
if (!isset($selected)) {
|
||||||
$selected[] = $field;
|
$selected[] = $field;
|
||||||
$selected_cnt = 1;
|
$selected_cnt = 1;
|
||||||
|
@@ -26,6 +26,7 @@ PMA_mysql_select_db($db);
|
|||||||
/**
|
/**
|
||||||
* The form used to define the structure of the table has been submitted
|
* The form used to define the structure of the table has been submitted
|
||||||
*/
|
*/
|
||||||
|
$abort = false;
|
||||||
if (isset($submit)) {
|
if (isset($submit)) {
|
||||||
$sql_query = $query_cpy = '';
|
$sql_query = $query_cpy = '';
|
||||||
|
|
||||||
@@ -141,7 +142,7 @@ if (isset($submit)) {
|
|||||||
$fulltext .= PMA_backquote($field_name[$j]) . ', ';
|
$fulltext .= PMA_backquote($field_name[$j]) . ', ';
|
||||||
}
|
}
|
||||||
} // end for
|
} // end for
|
||||||
unset($field_fulltext);
|
|
||||||
$fulltext = ereg_replace(', $', '', $fulltext);
|
$fulltext = ereg_replace(', $', '', $fulltext);
|
||||||
if (!empty($fulltext)) {
|
if (!empty($fulltext)) {
|
||||||
$sql_query .= ', FULLTEXT (' . $fulltext . ')';
|
$sql_query .= ', FULLTEXT (' . $fulltext . ')';
|
||||||
@@ -164,42 +165,53 @@ if (isset($submit)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Executes the query
|
// Executes the query
|
||||||
$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url);
|
$error_create = false;
|
||||||
$sql_query = $query_cpy . ';';
|
$result = PMA_mysql_query($sql_query) or $error_create = true;
|
||||||
unset($query_cpy);
|
|
||||||
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated;
|
|
||||||
|
|
||||||
// garvin: If comments were sent, enable relation stuff
|
if ($error_create == false) {
|
||||||
require('./libraries/relation.lib.php3');
|
$sql_query = $query_cpy . ';';
|
||||||
require('./libraries/transformations.lib.php3');
|
unset($query_cpy);
|
||||||
|
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated;
|
||||||
$cfgRelation = PMA_getRelationsParam();
|
|
||||||
|
// garvin: If comments were sent, enable relation stuff
|
||||||
// garvin: Update comment table, if a comment was set.
|
require('./libraries/relation.lib.php3');
|
||||||
if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) {
|
require('./libraries/transformations.lib.php3');
|
||||||
@reset($field_comments);
|
|
||||||
while(list($fieldindex, $fieldcomment) = each($field_comments)) {
|
$cfgRelation = PMA_getRelationsParam();
|
||||||
PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment);
|
|
||||||
|
// garvin: Update comment table, if a comment was set.
|
||||||
|
if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) {
|
||||||
|
@reset($field_comments);
|
||||||
|
while(list($fieldindex, $fieldcomment) = each($field_comments)) {
|
||||||
|
PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// garvin: Update comment table for mime types [MIME]
|
||||||
// garvin: Update comment table for mime types [MIME]
|
if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
|
||||||
if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
|
@reset($field_mimetype);
|
||||||
@reset($field_mimetype);
|
while(list($fieldindex, $mimetype) = each($field_mimetype)) {
|
||||||
while(list($fieldindex, $mimetype) = each($field_mimetype)) {
|
PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
|
||||||
PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include('./' . $cfg['DefaultTabTable']);
|
||||||
|
$abort = TRUE;
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
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 tbl_properties.inc.php3
|
||||||
|
$num_fields = $orig_num_fields;
|
||||||
|
$regenerate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
include('./' . $cfg['DefaultTabTable']);
|
|
||||||
exit();
|
|
||||||
} // end do create table
|
} // end do create table
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the form used to define the structure of the table
|
* Displays the form used to define the structure of the table
|
||||||
*/
|
*/
|
||||||
else {
|
if ($abort == FALSE) {
|
||||||
if (isset($num_fields)) {
|
if (isset($num_fields)) {
|
||||||
$num_fields = intval($num_fields);
|
$num_fields = intval($num_fields);
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,49 @@ else if ($action == 'tbl_addfield.php3') {
|
|||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
|
if (isset($num_fields)) {
|
||||||
|
?>
|
||||||
|
<input type="hidden" name="orig_num_fields" value="<?php echo $num_fields; ?>" />
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($after_field)) {
|
||||||
|
?>
|
||||||
|
<input type="hidden" name="orig_after_field" value="<?php echo $after_field; ?>" />
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($selected) && is_array($selected)) {
|
||||||
|
@reset($selected);
|
||||||
|
while(list($o_fld_nr, $o_fld_val) = each($selected)) {
|
||||||
|
?>
|
||||||
|
<input type="hidden" name="selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
|
||||||
|
<?php
|
||||||
|
if (!isset($true_selected)) {
|
||||||
|
?>
|
||||||
|
<input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($true_selected) && is_array($true_selected)) {
|
||||||
|
@reset($true_selected);
|
||||||
|
while(list($o_fld_nr, $o_fld_val) = each($true_selected)) {
|
||||||
|
?>
|
||||||
|
<input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} elseif (isset($field)) {
|
||||||
|
?>
|
||||||
|
<input type="hidden" name="orig_field" value="<?php echo urlencode($field); ?>" />
|
||||||
|
<input type="hidden" name="true_selected[] value="<?php echo (isset($orig_field) ? $orig_field : urlencode($field)); ?>" />
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
$is_backup = ($action != 'tbl_create.php3' && $action != 'tbl_addfield.php3');
|
$is_backup = ($action != 'tbl_create.php3' && $action != 'tbl_addfield.php3');
|
||||||
|
|
||||||
$header_cells = array();
|
$header_cells = array();
|
||||||
@@ -74,17 +117,74 @@ if (!$is_backup) {
|
|||||||
$header_cells[] = $strIdxFulltext;
|
$header_cells[] = $strIdxFulltext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)) {
|
||||||
|
@reset($field_fulltext);
|
||||||
|
while(list($fulltext_nr, $fulltext_indexkey) = each($field_fulltext)) {
|
||||||
|
$submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for ($i = 0 ; $i < $num_fields; $i++) {
|
for ($i = 0 ; $i < $num_fields; $i++) {
|
||||||
if (isset($fields_meta)) {
|
$submit_null = FALSE;
|
||||||
|
if (isset($regenerate) && $regenerate == TRUE) {
|
||||||
|
// 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) && isset($field_name[$i]) ? $field_name[$i] : FALSE);
|
||||||
|
$row['Type'] = (isset($field_type) && isset($field_type[$i]) ? $field_type[$i] : FALSE);
|
||||||
|
$row['Null'] = (isset($field_null) && isset($field_null[$i]) ? $field_null[$i] : '');
|
||||||
|
if ($row['Null'] == '') {
|
||||||
|
$submit_null = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'primary_' . $i) {
|
||||||
|
$row['Key'] = 'PRI';
|
||||||
|
} elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'index_' . $i) {
|
||||||
|
$row['Key'] = 'MUL';
|
||||||
|
} elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'unique_' . $i) {
|
||||||
|
$row['Key'] = 'UNI';
|
||||||
|
} else {
|
||||||
|
$row['Key'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$row['Default'] = (isset($field_default) && isset($field_default[$i]) ? $field_default[$i] : FALSE);
|
||||||
|
$row['Extra'] = (isset($field_extra) && isset($field_extra[$i]) ? $field_extra[$i] : FALSE);
|
||||||
|
$row['Comment'] = (isset($submit_fulltext) && isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : FALSE);
|
||||||
|
|
||||||
|
$submit_length = (isset($field_length) && isset($field_length[$i]) ? $field_length[$i] : FALSE);
|
||||||
|
$submit_attribute = (isset($field_attribute) && isset($field_attribute[$i]) ? $field_attribute[$i] : FALSE);
|
||||||
|
|
||||||
|
if (isset($field_comments) && isset($field_comments[$i])) {
|
||||||
|
$comments_map[$row['Field']] = $field_comments[$i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($field_mimetype) && isset($field_mimetype[$i])) {
|
||||||
|
$mime_map[$row['Field']]['mimetype'] = $field_mimetype[$i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($field_transformation) && isset($field_transformation[$i])) {
|
||||||
|
$mime_map[$row['Field']]['transformation'] = $field_transformation[$i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($field_transformation_options) && isset($field_transformation_options[$i])) {
|
||||||
|
$mime_map[$row['Field']]['transformation_options'] = $field_transformation_options[$i];
|
||||||
|
}
|
||||||
|
|
||||||
|
} elseif (isset($fields_meta)) {
|
||||||
$row = $fields_meta[$i];
|
$row = $fields_meta[$i];
|
||||||
}
|
}
|
||||||
|
|
||||||
$bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
|
$bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
|
||||||
|
|
||||||
// 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 chage.
|
||||||
$ci = 0;
|
$ci = 0;
|
||||||
|
|
||||||
if ($is_backup) {
|
if ($is_backup) {
|
||||||
$content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_orig[]" value="' . (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : '') . '" />' . "\n";
|
$backup_field = (isset($true_selected) && $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 {
|
} else {
|
||||||
$content_cells[$i][$ci] = '';
|
$content_cells[$i][$ci] = '';
|
||||||
}
|
}
|
||||||
@@ -119,6 +219,10 @@ for ($i = 0 ; $i < $num_fields; $i++) {
|
|||||||
$length = '';
|
$length = '';
|
||||||
}
|
}
|
||||||
} // end if else
|
} // end if else
|
||||||
|
|
||||||
|
if (isset($submit_length) && $submit_length != FALSE) {
|
||||||
|
$length = $submit_length;
|
||||||
|
}
|
||||||
|
|
||||||
for ($j = 0; $j < count($cfg['ColumnTypes']); $j++) {
|
for ($j = 0; $j < count($cfg['ColumnTypes']); $j++) {
|
||||||
$content_cells[$i][$ci] .= ' <option value="'. $cfg['ColumnTypes'][$j] . '"';
|
$content_cells[$i][$ci] .= ' <option value="'. $cfg['ColumnTypes'][$j] . '"';
|
||||||
@@ -161,6 +265,11 @@ for ($i = 0 ; $i < $num_fields; $i++) {
|
|||||||
if ($zerofill) {
|
if ($zerofill) {
|
||||||
$strAttribute = 'UNSIGNED ZEROFILL';
|
$strAttribute = 'UNSIGNED ZEROFILL';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($submit_attribute) && $submit_attribute != FALSE) {
|
||||||
|
$strAttribute = $submit_attribute;
|
||||||
|
}
|
||||||
|
|
||||||
for ($j = 0;$j < count($cfg['AttributeTypes']); $j++) {
|
for ($j = 0;$j < count($cfg['AttributeTypes']); $j++) {
|
||||||
$content_cells[$i][3] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
|
$content_cells[$i][3] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
|
||||||
if (strtoupper($strAttribute) == strtoupper($cfg['AttributeTypes'][$j])) {
|
if (strtoupper($strAttribute) == strtoupper($cfg['AttributeTypes'][$j])) {
|
||||||
@@ -174,7 +283,7 @@ for ($i = 0 ; $i < $num_fields; $i++) {
|
|||||||
|
|
||||||
$content_cells[$i][$ci] = '<select name="field_null[]" id="field_' . $i . '_5">';
|
$content_cells[$i][$ci] = '<select name="field_null[]" id="field_' . $i . '_5">';
|
||||||
|
|
||||||
if (!isset($row) || empty($row['Null'])) {
|
if ((!isset($row) || empty($row['Null']) || $row['Null'] == 'NOT NULL') && $submit_null == FALSE) {
|
||||||
$content_cells[$i][$ci] .= "\n";
|
$content_cells[$i][$ci] .= "\n";
|
||||||
$content_cells[$i][$ci] .= ' <option value="NOT NULL">not null</option>' . "\n";
|
$content_cells[$i][$ci] .= ' <option value="NOT NULL">not null</option>' . "\n";
|
||||||
$content_cells[$i][$ci] .= ' <option value="">null</option>' . "\n";
|
$content_cells[$i][$ci] .= ' <option value="">null</option>' . "\n";
|
||||||
@@ -277,7 +386,10 @@ for ($i = 0 ; $i < $num_fields; $i++) {
|
|||||||
&& empty($checked_index)
|
&& empty($checked_index)
|
||||||
&& empty($checked_unique)) {
|
&& empty($checked_unique)) {
|
||||||
$checked_none = ' checked="checked"';
|
$checked_none = ' checked="checked"';
|
||||||
|
} else {
|
||||||
|
$checked_none = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PMA_MYSQL_INT_VERSION >= 32323
|
if (PMA_MYSQL_INT_VERSION >= 32323
|
||||||
&&(isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
|
&&(isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
|
||||||
$checked_fulltext = ' checked="checked"';
|
$checked_fulltext = ' checked="checked"';
|
||||||
@@ -384,7 +496,7 @@ if ($action == 'tbl_create.php3' && PMA_MYSQL_INT_VERSION >= 32300) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="comment" size="40" maxlength="80" class="textfield" />
|
<input type="text" name="comment" size="40" maxlength="80" value="<?php echo (isset($comment) ? $comment : ''); ?>" class="textfield" />
|
||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
// BEGIN - Table Type - 2 May 2001 - Robbat2
|
// BEGIN - Table Type - 2 May 2001 - Robbat2
|
||||||
@@ -428,14 +540,14 @@ if ($action == 'tbl_create.php3' && PMA_MYSQL_INT_VERSION >= 32300) {
|
|||||||
<td width="25"> </td>
|
<td width="25"> </td>
|
||||||
<td>
|
<td>
|
||||||
<select name="tbl_type">
|
<select name="tbl_type">
|
||||||
<option value="Default"><?php echo $strDefault; ?></option>
|
<option <?php echo (isset($tbl_type) && $tbl_type == 'Default' ? 'selected="checked"' : ''); ?> value="Default"><?php echo $strDefault; ?></option>
|
||||||
<option value="MYISAM">MyISAM</option>
|
<option <?php echo (isset($tbl_type) && $tbl_type == 'MYISAM' ? 'selected="checked"' : ''); ?> value="MYISAM">MyISAM</option>
|
||||||
<option value="HEAP">Heap</option>
|
<option <?php echo (isset($tbl_type) && $tbl_type == 'HEAP' ? 'selected="checked"' : ''); ?> value="HEAP">Heap</option>
|
||||||
<option value="MERGE">Merge</option>
|
<option <?php echo (isset($tbl_type) && $tbl_type == 'MERGE' ? 'selected="checked"' : ''); ?> value="MERGE">Merge</option>
|
||||||
<?php if (isset($tbl_bdb)) { ?><option value="BDB">Berkeley DB</option><?php } ?>
|
<?php if (isset($tbl_bdb)) { ?><option <?php echo (isset($tbl_type) && $tbl_type == 'BDB' ? 'selected="checked"' : ''); ?> value="BDB">Berkeley DB</option><?php } ?>
|
||||||
<?php if (isset($tbl_gemini)) { ?><option value="GEMINI">Gemini</option><?php } ?>
|
<?php if (isset($tbl_gemini)) { ?><option <?php echo (isset($tbl_type) && $tbl_type == 'GEMINI' ? 'selected="checked"' : ''); ?> value="GEMINI">Gemini</option><?php } ?>
|
||||||
<?php if (isset($tbl_innodb)) { ?><option value="InnoDB">INNO DB</option><?php } ?>
|
<?php if (isset($tbl_innodb)) { ?><option <?php echo (isset($tbl_type) && $tbl_type == 'INNO DB' ? 'selected="checked"' : ''); ?> value="InnoDB">INNO DB</option><?php } ?>
|
||||||
<?php if (isset($tbl_isam)) { ?><option value="ISAM">ISAM</option><?php } ?>
|
<?php if (isset($tbl_isam)) { ?><option <?php echo (isset($tbl_type) && $tbl_type == 'ISAM' ? 'selected="checked"' : ''); ?> value="ISAM">ISAM</option><?php } ?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
|
Reference in New Issue
Block a user