diff --git a/tbl_properties_operations.php b/tbl_properties_operations.php index 12456b2c2..a2347f15a 100644 --- a/tbl_properties_operations.php +++ b/tbl_properties_operations.php @@ -10,7 +10,8 @@ require_once('./libraries/common.lib.php'); require('./tbl_properties_common.php'); //$err_url = 'tbl_properties_operations.php' . $err_url; $url_query .= '&goto=tbl_properties_operations.php&back=tbl_properties_operations.php'; - +$url_params['goto'] = 'tbl_properties_operations.php'; +$url_params['back'] = 'tbl_properties_operations.php'; /** * Gets relation settings @@ -26,80 +27,112 @@ require_once('./libraries/storage_engines.lib.php'); // reselect current db (needed in some cases probably due to // the calling of relation.lib.php) -PMA_DBI_select_db($db); - -$reread_info = FALSE; - -/** - * Updates table comment, type and options if required - */ -if (isset($submitcomment)) { - if (empty($prev_comment) || urldecode($prev_comment) != $comment) { - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\''; - $result = PMA_DBI_query($sql_query); - $message = $strSuccess; - $reread_info = TRUE; - } -} -if (isset($submittype)) { - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' TYPE = ' . $new_tbl_type; - $result = PMA_DBI_query($sql_query); - $message = $strSuccess; - $reread_info = TRUE; -} -if (isset($submitcollation)) { - // since something modifies $tbl_collation between the moment it is - // set from $_POST and this point, need to restore it - // (bug seen in MySQL 5.0.4) - $tbl_collation = $_POST['tbl_collation']; - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' DEFAULT' . PMA_generateCharsetQueryPart($tbl_collation); - $result = PMA_DBI_query($sql_query); - $message = $strSuccess; - unset($tbl_collation); - $reread_info = TRUE; -} -if (isset($submitoptions)) { - $sql_query = 'ALTER TABLE ' . PMA_backquote($table); - if ($tbl_type == 'MYISAM' || $tbl_type == 'ISAM') { - $sql_query .= isset($new_pack_keys) ? ' pack_keys=1': ' pack_keys=0'; - } - if ($tbl_type == 'MYISAM') { - $sql_query .= (isset($new_checksum) ? ' checksum=1': ' checksum=0') - . (isset($new_delay_key_write) ? ' delay_key_write=1': ' delay_key_write=0'); - } - // nijel: Here should be version check for InnoDB, however it is supported - // in 5.0.x x>4, 4.1.y y>12 and also works in 4.0.11, so I decided not to - // check for version - if ($tbl_type == 'MYISAM' || $tbl_type == 'INNODB') { - $sql_query .= !empty($new_auto_increment) ? ' auto_increment=' . PMA_sqlAddslashes($new_auto_increment) : ''; - } - $result = PMA_DBI_query($sql_query); - $message = $strSuccess; - $reread_info = TRUE; -} - -if ($reread_info) { - require('./libraries/tbl_properties_table_info.inc.php'); -} -unset($reread_info); - -/** - * Reordering the table has been requested by the user - */ -if (isset($submitorderby) && !empty($order_field)) { - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) - . ' ORDER BY ' . PMA_backquote(urldecode($order_field)); - if (isset($order_order) && $order_order == 'desc') { - $sql_query .= ' DESC'; - } - $result = PMA_DBI_query($sql_query); - $message = $result ? $strSuccess : $strError; -} // end if +PMA_DBI_select_db($GLOBALS['db']); /** * Gets tables informations */ -require_once('./libraries/tbl_properties_table_info.inc.php'); + +require_once('./libraries/tbl_move_copy.php'); +require('./libraries/tbl_properties_table_info.inc.php'); + + +$reread_info = false; +$errors = array(); +$table_alters = array(); + +/** + * Updates table comment, type and options if required + */ +if ( isset( $_REQUEST['submitoptions'] ) ) { + if ( isset( $_REQUEST['new_name'] ) && $_REQUEST['new_name'] !== $GLOBALS['table'] ) { + if ( trim($_REQUEST['new_name']) === '' ) { + $errors[] = $strTableEmpty; + } elseif ( strpos($_REQUEST['new_name'], '.') !== false ) { + $errors[] = $strError . ': ' . $_REQUEST['new_name']; + } else { + if ( PMA_table_rename( $GLOBALS['table'], $_REQUEST['new_name'] ) ) { + $message = sprintf($GLOBALS['strRenameTableOK'], + htmlspecialchars($GLOBALS['table']), htmlspecialchars($_REQUEST['new_name'])); + $GLOBALS['table'] = $_REQUEST['new_name']; + $reread_info = true; + $reload = true; + } else { + $errors[] = $strError . ': ' . $_REQUEST['new_name']; + } + } + } + if ( isset( $_REQUEST['comment'] ) + && urldecode($_REQUEST['prev_comment']) !== $_REQUEST['comment'] ) { + $table_alters[] = 'COMMENT = \'' . PMA_sqlAddslashes($_REQUEST['comment']) . '\''; + } + if ( ! empty( $_REQUEST['new_tbl_type'] ) + && strtolower($_REQUEST['new_tbl_type']) !== strtolower($tbl_type) ) { + $table_alters[] = 'TYPE = ' . $_REQUEST['new_tbl_type']; + $tbl_type = $_REQUEST['new_tbl_type']; + } + + if ( ! empty( $_REQUEST['tbl_collation'] ) + && $_REQUEST['tbl_collation'] !== $tbl_collation ) { + $table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']); + } + + $l_tbl_type = strtolower( $tbl_type ); + + $pack_keys = empty( $pack_keys ) ? '0' : '1'; + $_REQUEST['new_pack_keys'] = empty( $_REQUEST['new_pack_keys'] ) ? '0' : '1'; + if ( ( $l_tbl_type === 'myisam' || $l_tbl_type === 'isam' ) + && $_REQUEST['new_pack_keys'] !== $pack_keys ) { + $table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys']; + } + + $checksum = empty( $checksum ) ? '0' : '1'; + $_REQUEST['new_checksum'] = empty( $_REQUEST['new_checksum'] ) ? '0' : '1'; + if ( ( $l_tbl_type === 'myisam' ) + && $_REQUEST['new_checksum'] !== $checksum ) { + $table_alters[] = 'checksum = ' . $_REQUEST['new_checksum']; + } + + $delay_key_write = empty( $delay_key_write ) ? '0' : '1'; + $_REQUEST['new_delay_key_write'] = empty( $_REQUEST['new_delay_key_write'] ) ? '0' : '1'; + if ( ( $l_tbl_type === 'myisam' ) + && $_REQUEST['new_delay_key_write'] !== $delay_key_write ) { + $table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write']; + } + + if ( ( $l_tbl_type === 'myisam' || $l_tbl_type === 'innodb' ) + && ! empty( $_REQUEST['new_auto_increment'] ) + && ( ! isset( $auto_increment ) || $_REQUEST['new_auto_increment'] !== $auto_increment ) ) { + $table_alters[] = 'auto_increment = ' . PMA_sqlAddslashes($_REQUEST['new_auto_increment']); + } + + if ( count($table_alters) > 0 ) { + $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']); + $sql_query .= "\r\n" . implode("\r\n", $table_alters); + $message = PMA_DBI_query($sql_query) ? $strSuccess : $strError; + $reread_info = true; + unset( $table_alters ); + } +} +/** + * Reordering the table has been requested by the user + */ +if ( isset( $_REQUEST['submitorderby'] ) && ! empty( $_REQUEST['order_field'] ) ) { + $sql_query = ' + ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' + ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field'])); + if ( isset( $_REQUEST['order_order'] ) && $_REQUEST['order_order'] === 'desc' ) { + $sql_query .= ' DESC'; + } + $message = PMA_DBI_query($sql_query) ? $strSuccess : $strError; +} // end if + + +if ( $reread_info ) { + $pack_keys = $checksum = $delay_key_write = 0; + require('./libraries/tbl_properties_table_info.inc.php'); +} +unset( $reread_info ); /** * Displays top menu links @@ -109,427 +142,314 @@ require_once('./libraries/tbl_properties_links.inc.php'); /** * Get columns names */ -$local_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db); -$result = PMA_DBI_query($local_query); -for ($i = 0; $row = PMA_DBI_fetch_assoc($result); $i++) { - $columns[$i] = $row['Field']; -} -PMA_DBI_free_result($result); -unset($result); -?> - - -= 32334) { - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5.0.4, >4.1.12 and >4.0.11, so I decided not to +// check for version ?> + + + + + +
+ + +
-   - - - -
- :  - - -
-   - - -
- - - - -
- +' + . htmlspecialchars($fieldname) . '' . "\n"; +} +unset($columns); +?> + + + + + + + +
+ + + +
+ + -  .  - -
- -
- - - -
- +  .  + + + + + + +
+ + +
+ + -  .  - -
-   
-   
-   
+ +  .  +
+ + +
+ +
+ +
+ + +
+ +
+ + +
+ + /> + + +
+ +
+ -   
-
- -
- - style="vertical-align: middle" />   -
- -
+ + + + + - - - - - - - - - + + + + + - + + - PMA_DBI_free_result($result); - echo "\n"; - ?> - - - - - - - - - - - = 40100) { - echo "\n" - . '' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; - } - // PACK_KEYS: MyISAM or ISAM - // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only - // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3 - - // nijel: Here should be version check for InnoDB, however it is supported - // in 5.0.x x>4, 4.1.y y>12 and also works in 4.0.11, so I decided not to - // check for version - if ($tbl_type == 'MYISAM' || $tbl_type == 'ISAM' || $tbl_type == 'INNODB') { - ?> - - - - - - - - - - - = 40100) { + ?> + + + + + + + + + + + + + + + + + + + 0 + && ( $tbl_type == 'MYISAM' || $tbl_type == 'INNODB' ) ) { + ?> + + + + -
+
- -   -
-   - - -
+
+ + +
- - :  - -
- - - -
' . "\n" - . PMA_generate_common_hidden_inputs($db, $table, 3) - . ' ' . $strCollation . ': ' . "\n" - . '
' . "\n" - . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', NULL, $tbl_collation, FALSE, 3) - . ' ' . "\n" - . ' ' . "\n" - . '
- :  - -
- - style="vertical-align: middle" />
- - style="vertical-align: middle" />
- - style="vertical-align: middle" />
- - - style="width: 30px; vertical-align: middle" />  -
- -
+
/> +
/> +
/> +
- - - - - - +
- -
+ +
+ +
+ + +

+ + - - -
- $arr) { - $join_query = 'SELECT ' . PMA_backquote($table) . '.* FROM ' - . PMA_backquote($table) . ' LEFT JOIN ' - . PMA_backquote($arr['foreign_table']); - if ($arr['foreign_table'] == $table) { - $foreign_table = $table . '1'; - $join_query .= ' AS ' . PMA_backquote($foreign_table); - } else { - $foreign_table = $arr['foreign_table']; - } - $join_query .= ' ON ' - . PMA_backquote($table) . '.' . PMA_backquote($master) - . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field']) - . ' WHERE ' - . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field']) - . ' IS NULL AND ' - . PMA_backquote($table) . '.' . PMA_backquote($master) - . ' IS NOT NULL'; - echo ' ' - . '' . $master . ' -> ' . $arr['foreign_table'] . '.' . $arr['foreign_field'] - . '
' . "\n"; - unset($foreign_table); - unset($join_query); - } // end while - ?> - - + - -