diff --git a/tbl_change.php b/tbl_change.php index 07e2a53dd..bd5d3ff69 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -65,11 +65,11 @@ if (empty($GLOBALS['goto'])) { * @todo check if we could replace by "db_|tbl_" - please clarify!? */ $_url_params = array( - 'db' => $db, + 'db' => $db, 'sql_query' => $sql_query ); -if ( preg_match('@^tbl_@', $GLOBALS['goto'])) { +if (preg_match('@^tbl_@', $GLOBALS['goto'])) { $_url_params['table'] = $table; } @@ -79,7 +79,7 @@ unset($_url_params); /** * Sets parameters for links - * where is this varaibel used? + * where is this variable used? * replace by PMA_generate_common_url($url_params); */ $url_query = PMA_generate_common_url($url_params, 'html', ''); @@ -140,6 +140,7 @@ require_once './libraries/tbl_links.inc.php'; /** * Get the analysis of SHOW CREATE TABLE for this table + * @todo should be handled by class Table */ $show_create_table = PMA_DBI_fetch_value( 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), @@ -151,8 +152,11 @@ unset($show_create_table); * Get the list of the fields of the current table */ PMA_DBI_select_db($db); -$table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE); +$trow_table_def = PMA_DBI_fetch_result('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', + null, null, null, PMA_DBI_QUERY_STORE); if (isset($primary_key)) { + // when in edit mode load all selected rows from table + $insert_mode = false; if (is_array($primary_key)) { $primary_key_array = $primary_key; } else { @@ -183,8 +187,9 @@ if (isset($primary_key)) { } } } else { + // no primary key given, just load first row - but what happens if tbale is empty? + $insert_mode = true; $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE); - unset($row); } // @@ -203,9 +208,9 @@ $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5) : 'onchange'; // Had to put the URI because when hosted on an https server, // some browsers send wrongly this form to the http server. -?> - +if ($cfg['CtrlArrowsMoving']) { + ?> - + -
> - - - - - $db, + 'table' => $table, + 'goto' => $GLOBALS['goto'], + 'err_url' => $err_url, + 'sql_query' => $sql_query, +); if (isset($primary_keys)) { foreach ($primary_key_array as $rowcount => $primary_key) { - echo ''. "\n"; + $_form_params['primary_key[' . $rowcount . ']'] = trim($primary_key); } } -echo "\n"; -if ($cfg['PropertiesIconic'] === true || $cfg['PropertiesIconic'] === 'both') { - if ($cfg['PropertiesIconic'] === 'both') { - $iconic_spacer = '
'; - } else { - $iconic_spacer = ''; - } +?> + +> +'; - - if ($cfg['PropertiesIconic'] === 'both') { - $titles['Browse'] .= ' ' . $strBrowseForeignValues . '
'; - } -} else { - $titles['Browse'] = $strBrowseForeignValues; -} +$titles['Browse'] = PMA_getIcon('b_browse.png', $strBrowseForeignValues); // Set if we passed the first timestamp field $timestamp_seen = 0; -$fields_cnt = PMA_DBI_num_rows($table_def); +$fields_cnt = count($trow_table_def); // Set a flag here because the 'if' would not be valid in the loop // if we set a value in some field -$insert_mode = (!isset($row) ? TRUE : FALSE); if ($insert_mode) { $loop_array = array(); for ($i = 0; $i < $cfg['InsertRows']; $i++) { - $loop_array[] = FALSE; + $loop_array[] = false; } } else { $loop_array = $row; } -while ($trow = PMA_DBI_fetch_assoc($table_def)) { - $trow_table_def[] = $trow; -} - $tabindex = 0; $tabindex_for_function = +1000; $tabindex_for_null = +2000;