Update and display column comments in Add/Edit Fieldmode and CREATE table mode. Display comments in table structure (optional) with underlined CSS-mouseovers. Display comments in browser mode (optional), both in vertical and horizontal display mode. Keep column comments in synch, when DROPping/ALTERing and moving/copying tables.

This commit is contained in:
Garvin Hicking
2003-02-24 16:59:36 +00:00
parent 820ad9c0cd
commit 30b1873e61
15 changed files with 191 additions and 54 deletions

View File

@@ -113,6 +113,9 @@ if (isset($new_name) && trim($new_name) != '') {
$sql_query .= "\n\n" . $sql_insert_data;
}
include('./libraries/relation.lib.php3');
$cfgRelation = PMA_getRelationsParam();
// Drops old table if the user has requested to move it
if (isset($submit_move)) {
$sql_drop_table = 'DROP TABLE ' . $source;
@@ -121,9 +124,44 @@ if (isset($new_name) && trim($new_name) != '') {
include('./header.inc.php3');
PMA_mysqlDie('', $sql_drop_table, '', $err_url);
}
// garvin: Move old entries from comments to new table
if ($cfgRelation['commwork']) {
$remove_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_comments'])
. ' SET table_name = \'' . PMA_sqlAddslashes($new_name) . '\', '
. ' db_name = \'' . PMA_sqlAddslashes($target_db) . '\''
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($rmv_query);
}
$sql_query .= "\n\n" . $sql_drop_table . ';';
$db = $target_db;
$table = $new_name;
} else {
// garvin: Create new entries as duplicates from old comments
if ($cfgRelation['commwork']) {
// Get all comments and MIME-Types for current table
$comments_copy_query = 'SELECT
column_name, ' . PMA_backquote('comment') . '
FROM ' . PMA_backquote($cfgRelation['column_comments']) . '
WHERE
db_name = \'' . PMA_sqlAddslashes($db) . '\' AND
table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$comments_copy_rs = PMA_query_as_cu($comments_copy_query);
// Write every comment as new copied entry. [MIME]
while ($comments_copy_row = @PMA_mysql_fetch_array($comments_copy_rs)) {
$new_comment_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['column_comments'])
. ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ') '
. ' VALUES('
. '\'' . PMA_sqlAddslashes($target_db) . '\','
. '\'' . PMA_sqlAddslashes($new_name) . '\','
. '\'' . PMA_handleSlashes($comments_copy_row['comment']) . '\')';
$new_comment_rs = PMA_query_as_cu($new_comment_query);
} // end while
}
}
$message = (isset($submit_move) ? $strMoveTableOK : $strCopyTableOK);