diff --git a/ChangeLog b/ChangeLog index 632b15a84..85318d456 100755 --- a/ChangeLog +++ b/ChangeLog @@ -6,8 +6,15 @@ $Id$ $Source$ 2003-03-12 Garvin Hicking - * New $sql_structure variable for the new table export design broke - DB export functionality. Fixed this. + * sql.php3, tbl_alter.php3, tbl_move_copy.php3, tbl_properties_structure.php3, + tbl_rename.php3, libraries/relation.lib.php3: + Bugfix #579256 / RFE #577328 : Automatic update of relations, + display fields, comments, bookmarks, ... on update, delete and duplicate. + Automatic duplication/moving of PDF pages does not yet work. Would the + original author please be so kind to have a look at the tbl_move_copy.php + script, search for '[TODO]' and apply necessary fixes? ;) + * tbl_dump.php3: New $sql_structure variable for the new table export + design broke DB export functionality. Fixed this. 2003-03-12 Marc Delisle * lang/ukrainian: update, thanks to Markijan Baran diff --git a/libraries/relation.lib.php3 b/libraries/relation.lib.php3 index e900cdae6..b86fdd14f 100644 --- a/libraries/relation.lib.php3 +++ b/libraries/relation.lib.php3 @@ -82,6 +82,7 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){ $cfgRelation = array(); $cfgRelation['relwork'] = FALSE; $cfgRelation['displaywork'] = FALSE; + $cfgRelation['bookmarkwork']= FALSE; $cfgRelation['pdfwork'] = FALSE; $cfgRelation['commwork'] = FALSE; $cfgRelation['mimework'] = FALSE; @@ -118,7 +119,7 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){ while ($curr_table = @PMA_mysql_fetch_array($tab_rs)) { if ($curr_table[0] == $cfg['Server']['bookmarktable']) { - continue; + $cfgRelation['bookmark'] = $curr_table[0]; } else if ($curr_table[0] == $cfg['Server']['relation']) { $cfgRelation['relation'] = $curr_table[0]; } else if ($curr_table[0] == $cfg['Server']['table_info']) { @@ -176,9 +177,14 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){ $cfgRelation['historywork'] = TRUE; } + if (isset($cfgRelation['bookmark'])) { + $cfgRelation['bookmarkwork'] = TRUE; + } + if ($cfgRelation['relwork'] == TRUE && $cfgRelation['displaywork'] == TRUE && $cfgRelation['pdfwork'] == TRUE && $cfgRelation['commwork'] == TRUE - && $cfgRelation['mimework'] && $cfgRelation['historywork']) { + && $cfgRelation['mimework'] == TRUE && $cfgRelation['historywork'] == TRUE + && $cfgRelation['bookmarkwork'] == TRUE) { $cfgRelation['allworks'] = TRUE; } if ($tab_rs) { @@ -232,6 +238,9 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){ echo ' ' . $GLOBALS['strColComFeat'] . ': ' . (($cfgRelation['commwork'] == TRUE) ? $enabled : $disabled) . '' . "\n"; + echo ' ' . $GLOBALS['strBookmarkQuery'] . ': ' + . (($cfgRelation['bookmarkwork'] == TRUE) ? $enabled : $disabled) + . '' . "\n"; echo ' MIME: ' . (($cfgRelation['mimework'] == TRUE) ? $enabled : $disabled) . '' . "\n"; diff --git a/sql.php3 b/sql.php3 index 14da68f28..f32cf1693 100755 --- a/sql.php3 +++ b/sql.php3 @@ -181,6 +181,9 @@ if ($do_confirm) { + + + @@ -430,27 +433,144 @@ else { } // end rows total count // garvin: if a table or database gets dropped, check column comments. - if (isset($purge)) { + if (isset($purge) && $purge == '1') { include('./libraries/relation.lib.php3'); $cfgRelation = PMA_getRelationsParam(); - if ($cfgRelation['commwork']) { - if (isset($table) && isset($db) && !empty($table) && !empty($db)) { - $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info']) + if (isset($table) && isset($db) && !empty($table) && !empty($db)) { + // garvin: Only a table is deleted. Remove all references in PMA_* + if ($cfgRelation['commwork']) { + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info']) + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + } + + if ($cfgRelation['displaywork']) { + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''; $rmv_rs = PMA_query_as_cu($remove_query); unset($rmv_query); - } elseif (isset($db) && !empty($db)) { + } + + if ($cfgRelation['pdfwork']) { + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + } + + if ($cfgRelation['relwork']) { + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) + . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) + . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + } + } elseif (isset($db) && !empty($db)) { + // garvin: A whole DB gets deleted. Remove all references in PMA_* + if ($cfgRelation['commwork']) { $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; $rmv_rs = PMA_query_as_cu($remove_query); unset($rmv_query); } - } // end if relation-stuff - } // end if ($purge) - } // end else "didn't ask to see php code" + if ($cfgRelation['bookmarkwork']) { + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['bookmark']) + . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + } + + if ($cfgRelation['displaywork']) { + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info']) + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + } + + if ($cfgRelation['pdfwork']) { + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['pdf_pages']) + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + } + + if ($cfgRelation['relwork']) { + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) + . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) + . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + } + + } else { + // garvin: VOID. No DB/Table gets deleted. + } // end if relation-stuff + } // end if ($purge) + + // garvin: If a column gets dropped, do relation magic. + if (isset($cpurge) && $cpurge == '1' && isset($purgekey) + && isset($db) && isset($table) + && !empty($db) && !empty($table) && !empty($purgekey)) { + include('./libraries/relation.lib.php3'); + $cfgRelation = PMA_getRelationsParam(); + + if ($cfgRelation['commwork']) { + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info']) + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' + . ' AND column_name = \'' . PMA_sqlAddslashes(urldecode($purgekey)) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + } + + if ($cfgRelation['displaywork']) { + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info']) + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'' + . ' AND display_field = \'' . PMA_sqlAddslashes(urldecode($purgekey)) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + } + + if ($cfgRelation['relwork']) { + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) + . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'' + . ' AND master_field = \'' . PMA_sqlAddslashes(urldecode($purgekey)) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + + $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation']) + . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\'' + . ' AND foreign_field = \'' . PMA_sqlAddslashes(urldecode($purgekey)) . '\''; + $rmv_rs = PMA_query_as_cu($remove_query); + unset($rmv_query); + } + } // end if column PMA_* purge + } // end else "didn't ask to see php code" + // No rows returned -> move back to the calling page if ($num_rows < 1 || $is_affected) { diff --git a/tbl_alter.php3 b/tbl_alter.php3 index 0ccc9530c..aae5ba006 100755 --- a/tbl_alter.php3 +++ b/tbl_alter.php3 @@ -99,6 +99,45 @@ if (isset($submit)) { PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, $field_orig[$fieldindex]); } } + + // garvin: Rename relations&display fields, if altered. + if (($cfgRelation['displaywork'] || $cfgRelation['relwork']) && isset($field_orig) && is_array($field_orig)) { + @reset($field_orig); + while(list($fieldindex, $fieldcontent) = each($field_orig)) { + if ($field_name[$fieldindex] != $fieldcontent) { + if ($cfgRelation['displaywork']) { + $table_query = 'UPDATE ' . 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($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($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']) { diff --git a/tbl_move_copy.php3 b/tbl_move_copy.php3 index 0b6c37406..ac0007769 100644 --- a/tbl_move_copy.php3 +++ b/tbl_move_copy.php3 @@ -23,6 +23,79 @@ function PMA_myHandler($sql_insert = '') $sql_insert_data .= $sql_insert . ';' . "\n"; } // end of the 'PMA_myHandler()' function +/** + * Inserts existing entries in a PMA_* table by reading a value from an old entry + * + * @param string The array index, which Relation feature to check + * ('relwork', 'commwork', ...) + * @param string The array index, which PMA-table to update + * ('bookmark', 'relation', ...) + * @param array Which fields will be SELECT'ed from the old entry + * @param array Which fields will be used for the WHERE query + * (array('FIELDNAME' => 'FIELDVALUE')) + * @param array Which fields will be used as new VALUES. These are the important + * keys which differ from the old entry. + * (array('FIELDNAME' => 'NEW FIELDVALUE')) + + * @global string relation variable + * + * @author Garvin Hicking + */ +function PMA_duplicate_table($work, $pma_table, $get_fields, $where_fields, $new_fields) { +global $cfgRelation; + + $last_id = -1; + + if ($cfgRelation[$work]) { + @reset($get_fields); + $select_parts = array(); + $row_fields = array(); + while(list($nr, $get_field) = each($get_fields)) { + $select_parts[] = PMA_backquote($get_field); + $row_fields[$get_field] = 'cc'; + } + + @reset($where_fields); + $where_parts = array(); + while(list($_where, $_value) = each($where_fields)) { + $where_parts[] = PMA_backquote($_where) . ' = \'' . PMA_sqlAddslashes($_value) . '\''; + } + + @reset($new_fields); + $new_parts = array(); + $new_value_parts = array(); + while(list($_where, $_value) = each($new_fields)) { + $new_parts[] = PMA_backquote($_where); + $new_value_parts[] = PMA_sqlAddslashes($_value); + } + + $table_copy_query = 'SELECT ' . implode(', ', $select_parts) + . ' FROM ' . PMA_backquote($cfgRelation[$pma_table]) + . ' WHERE ' . implode(' AND ', $where_parts); + $table_copy_rs = PMA_query_as_cu($table_copy_query); + + while ($table_copy_row = @PMA_mysql_fetch_array($table_copy_rs)) { + $value_parts = array(); + while(list($_key, $_val) = each($table_copy_row)) { + if (isset($row_fields[$_key]) && $row_fields[$_key] == 'cc') { + $value_parts[] = PMA_sqlAddslashes($_val); + } + } + + $new_table_query = 'INSERT INTO ' . PMA_backquote($cfgRelation[$pma_table]) + . ' (' . implode(', ', $select_parts) . ', ' . implode(', ', $new_parts) . ')' + . ' VALUES ' + . ' (\'' . implode('\', \'', $value_parts) . '\', \'' . implode('\', \'', $new_value_parts) . '\')'; + + $new_table_rs = PMA_query_as_cu($new_table_query); + $last_id = (@function_exists('mysql_insert_id') ? @mysql_insert_id() : -1); + } // end while + + return $last_id; + } + + return true; +} // end of 'PMA_duplicate_table()' function /** * Gets some core libraries @@ -116,7 +189,7 @@ if (isset($new_name) && trim($new_name) != '') { PMA_mysqlDie('', $sql_drop_table, '', $err_url); } - // garvin: Move old entries from comments to new table + // garvin: Move old entries from PMA-DBs to new table if ($cfgRelation['commwork']) { $remove_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info']) . ' SET table_name = \'' . PMA_sqlAddslashes($new_name) . '\', ' @@ -126,52 +199,154 @@ if (isset($new_name) && trim($new_name) != '') { $rmv_rs = PMA_query_as_cu($remove_query); unset($rmv_query); } + + // garvin: updating bookmarks is not possible since only a single table is moved, + // and not the whole DB. + // if ($cfgRelation['bookmarkwork']) { + // $remove_query = 'UPDATE ' . PMA_backquote($cfgRelation['bookmark']) + // . ' SET dbase = \'' . PMA_sqlAddslashes($target_db) . '\'' + // . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''; + // $rmv_rs = PMA_query_as_cu($remove_query); + // unset($rmv_query); + // } + + if ($cfgRelation['displaywork']) { + $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_info']) + . ' SET db_name = \'' . PMA_sqlAddslashes($target_db) . '\', ' + . ' table_name = \'' . PMA_sqlAddslashes($new_name) . '\'' + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''; + $tb_rs = PMA_query_as_cu($table_query); + unset($table_query); + unset($tb_rs); + } + + if ($cfgRelation['relwork']) { + $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation']) + . ' SET foreign_table = \'' . PMA_sqlAddslashes($new_name) . '\',' + . ' foreign_db = \'' . PMA_sqlAddslashes($target_db) . '\'' + . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\''; + $tb_rs = PMA_query_as_cu($table_query); + unset($table_query); + unset($tb_rs); + + $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['relation']) + . ' SET master_table = \'' . PMA_sqlAddslashes($new_name) . '\',' + . ' master_db = \'' . PMA_sqlAddslashes($target_db) . '\'' + . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''; + $tb_rs = PMA_query_as_cu($table_query); + unset($table_query); + unset($tb_rs); + } + + // garvin: [TODO] Can't get moving PDFs the right way. The page numbers always + // get screwed up independently from duplication because the numbers do not + // seem to be stored on a per-database basis. Would the author of pdf support + // please have a look at it? + + /* + if ($cfgRelation['pdfwork']) { + $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_coords']) + . ' 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) . '\''; + $tb_rs = PMA_query_as_cu($table_query); + unset($table_query); + unset($tb_rs); + + $pdf_query = 'SELECT pdf_page_number ' + . ' FROM ' . PMA_backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . PMA_sqlAddslashes($target_db) . '\'' + . ' AND table_name = \'' . PMA_sqlAddslashes($new_name) . '\''; + $pdf_rs = PMA_query_as_cu($pdf_query); + + while ($pdf_copy_row = @PMA_mysql_fetch_array($pdf_rs)) { + $table_query = 'UPDATE ' . PMA_backquote($cfgRelation['pdf_pages']) + . ' SET db_name = \'' . PMA_sqlAddslashes($target_db) . '\'' + . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' + . ' AND page_nr = \'' . PMA_sqlAddslashes($pdf_copy_row['pdf_page_number']) . '\''; + $tb_rs = PMA_query_as_cu($table_query); + unset($table_query); + unset($tb_rs); + } + } + */ $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']) { - // 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') . ', mimetype, transformation, transformation_options) ' - . ' VALUES(' - . '\'' . PMA_sqlAddslashes($target_db) . '\',' - . '\'' . PMA_sqlAddslashes($new_name) . '\',' - . '\'' . PMA_sqlAddslashes($comments_copy_row['column_name']) . '\',' - . '\'' . PMA_sqlAddslashes($comments_copy_row['comment']) . '\',' - . '\'' . PMA_sqlAddslashes($comments_copy_row['mimetype']) . '\',' - . '\'' . PMA_sqlAddslashes($comments_copy_row['transformation']) . '\',' - . '\'' . PMA_sqlAddslashes($comments_copy_row['transformation_options']) . '\')'; - $new_comment_rs = PMA_query_as_cu($new_comment_query); - } // end while + // garvin: Create new entries as duplicates from old PMA DBs + if ($what != 'dataonly') { + if ($cfgRelation['commwork']) { + // Get all comments and MIME-Types for current table + $comments_copy_query = 'SELECT + column_name, ' . PMA_backquote('comment') . ($cfgRelation['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ' + FROM ' . PMA_backquote($cfgRelation['column_info']) . ' + 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_info']) + . ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ($cfgRelation['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ') ' + . ' VALUES(' + . '\'' . PMA_sqlAddslashes($target_db) . '\',' + . '\'' . PMA_sqlAddslashes($new_name) . '\',' + . '\'' . PMA_sqlAddslashes($comments_copy_row['column_name']) . '\'' + . ($cfgRelation['mimework'] ? ',\'' . PMA_sqlAddslashes($comments_copy_row['comment']) . '\',' + . '\'' . PMA_sqlAddslashes($comments_copy_row['mimetype']) . '\',' + . '\'' . PMA_sqlAddslashes($comments_copy_row['transformation']) . '\',' + . '\'' . PMA_sqlAddslashes($comments_copy_row['transformation_options']) . '\'' : '') + . ')'; + $new_comment_rs = PMA_query_as_cu($new_comment_query); + } // end while + } + + if ($db != $target_db) { + $get_fields = array('user','label','query'); + $where_fields = array('dbase' => $db); + $new_fields = array('dbase' => $target_db); + PMA_duplicate_table('bookmarkwork', 'bookmark', $get_fields, $where_fields, $new_fields); + } + + $get_fields = array('display_field'); + $where_fields = array('db_name' => $db, 'table_name' => $table); + $new_fields = array('db_name' => $target_db, 'table_name' => $new_name); + PMA_duplicate_table('displaywork', 'table_info', $get_fields, $where_fields, $new_fields); + + $get_fields = array('master_field', 'foreign_db', 'foreign_table', 'foreign_field'); + $where_fields = array('master_db' => $db, 'master_table' => $table); + $new_fields = array('master_db' => $target_db, 'master_table' => $new_name); + PMA_duplicate_table('relwork', 'relation', $get_fields, $where_fields, $new_fields); + + $get_fields = array('foreign_field', 'master_db', 'master_table', 'master_field'); + $where_fields = array('foreign_db' => $db, 'foreign_table' => $table); + $new_fields = array('foreign_db' => $target_db, 'foreign_table' => $new_name); + PMA_duplicate_table('relwork', 'relation', $get_fields, $where_fields, $new_fields); + + // garvin: [TODO] Can't get duplicating PDFs the right way. The page numbers always + // get screwed up independently from duplication because the numbers do not + // seem to be stored on a per-database basis. Would the author of pdf support + // please have a look at it? + /* + $get_fields = array('page_descr'); + $where_fields = array('db_name' => $db); + $new_fields = array('db_name' => $target_db); + $last_id = PMA_duplicate_table('pdfwork', 'pdf_pages', $get_fields, $where_fields, $new_fields); - // Get all comments and MIME-Types for current table - $comments_copy_query = 'SELECT - column_name, ' . PMA_backquote('comment') . ($cfgRelation['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ' - FROM ' . PMA_backquote($cfgRelation['column_info']) . ' - 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_info']) - . ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ($cfgRelation['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ') ' - . ' VALUES(' - . '\'' . PMA_sqlAddslashes($target_db) . '\',' - . '\'' . PMA_sqlAddslashes($new_name) . '\',' - . '\'' . PMA_sqlAddslashes($comments_copy_row['column_name']) . '\'' - . ($cfgRelation['mimework'] ? ',\'' . PMA_sqlAddslashes($comments_copy_row['comment']) . '\',' - . '\'' . PMA_sqlAddslashes($comments_copy_row['mimetype']) . '\',' - . '\'' . PMA_sqlAddslashes($comments_copy_row['transformation']) . '\',' - . '\'' . PMA_sqlAddslashes($comments_copy_row['transformation_options']) . '\'' : '') - . ')'; - $new_comment_rs = PMA_query_as_cu($new_comment_query); - } // end while + if (isset($last_id) && $last_id >= 0) { + $get_fields = array('x', 'y'); + $where_fields = array('db_name' => $db, 'table_name' => $table); + $new_fields = array('db_name' => $target_db, 'table_name' => $new_name, 'pdf_page_number' => $last_id); + PMA_duplicate_table('pdfwork', 'table_coords', $get_fields, $where_fields, $new_fields); + } + */ } } diff --git a/tbl_properties_structure.php3 b/tbl_properties_structure.php3 index 258434ec7..545a01b31 100755 --- a/tbl_properties_structure.php3 +++ b/tbl_properties_structure.php3 @@ -184,7 +184,7 @@ while ($row = PMA_mysql_fetch_array($fields_rs)) { if ($fields_cnt > 1) { echo "\n"; ?> -