diff --git a/ChangeLog b/ChangeLog index 7744076a9..b72b2af58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,12 @@ phpMyAdmin - ChangeLog $Id$ $HeadURL$ +2006-12-19 Sebastian Mendel + * tbl_change.php, tbl_replace.php, include/tbl_replace_fields.inc.php: + refactored: made register_globals independent; added documentation; + removed unused code; fixed bug #1597686 last insert id message wrong; + much more i don't remember ... + 2006-12-15 Marc Delisle * Documentation.html, libraries/common.lib.php, config.default.php: bug #1615313, doc referred to HTTP so enable the code to accept @@ -41,7 +47,7 @@ $HeadURL$ only one IP address, thanks to Christian Schmidt 2006-12-06 Marc Delisle - * libraries/import.lib.php, /common.lib.php: bug #1603660, + * libraries/import.lib.php, /common.lib.php: bug #1603660, incorrect escaping of ">" * server_variables.php: bug #1589611, problem on 64-bit systems @@ -74,7 +80,7 @@ $HeadURL$ 2006-11-23 Marc Delisle * pmd/scripts/move.js: fix a few js errors - * pmd*.php: remove unneeded calls to getRelationsParam(); + * pmd*.php: remove unneeded calls to getRelationsParam(); verify if the internal relations are enabled before trying to create one @@ -149,7 +155,7 @@ $HeadURL$ 2006-11-11 Marc Delisle * pmd_general.php, pmd_get_info.php, pmd/scripts/move.js, lang/*: - in InnoDB, it's allowed to create a relation even if it's not on + in InnoDB, it's allowed to create a relation even if it's not on a primary key, so display the InnoDB-related options (ON UPDATE, ON CASCADE) @@ -254,7 +260,7 @@ $HeadURL$ * Documentation.html, libraries/tbl_properties.inc.php, libraries/config.default.php: Allow to edit small number of fields vertically and lange number horizontally (RFE #1581773). - * [too much files]: + * [too much files]: - Rename tbl_* files to drop useless _properties part. - Rename db_* files to drop useless _details part. * libraries/Config.class.php: Add backward compatibility code to affect @@ -277,7 +283,7 @@ $HeadURL$ 2006-10-18 Marc Delisle * db_operations.php, libraries/Table.class.php: bug #1567316, renaming a db containing a view - + 2006-10-18 Michal Čihař * libraries/transformations/text_plain__dateformat.inc.php, lang/*: Support displaying in UTC (RFE #1440386). @@ -321,7 +327,7 @@ $HeadURL$ * export.php, db_details_export.php: bug #1541189, views are not displayed in export list; However I'm still not sure what should be done if a user only chooses - a view. In the past we ensured to avoid exporting data from a view + a view. In the past we ensured to avoid exporting data from a view because it would create redundant data in the export file 2006-10-13 Marc Delisle @@ -337,7 +343,7 @@ $HeadURL$ * libraries/cleanup.lib.php, libraries/common.lib.php: Move cleanup to separate function (bug #1569123). * changelog.php: Switch to subversion. - * main.php: + * main.php: - Mention wiki. - Switch to subversion. * libraries/export/csv.php: Fix cvs/csv typo (bug #1583509). @@ -407,7 +413,7 @@ $HeadURL$ 2006-10-05 Marc Delisle * scripts/create-release.sh: starting changes for new kits TODO: - trimming of libraries/select_lang.lib.php in the kit - - 7zip + - 7zip - remove gzip ? 2006-10-04 Michal Čihař @@ -429,7 +435,7 @@ $HeadURL$ 2006-10-01 Marc Delisle ### 2.9.0.1 released from MAINT_2_9_0 - * libraries/database_interface.lib.php: bug #1568341, + * libraries/database_interface.lib.php: bug #1568341, case sensitivity in database names * tbl_relation.php: trap error 1452 when adding a foreign key and a constraint fails @@ -454,7 +460,7 @@ $HeadURL$ * libraries/common.lib.php: bug #1519859, avoid overflow on 64-bit machines 2006-09-22 Marc Delisle - * libraries/tbl_properties_links.inc.php: bug #1560152, + * libraries/tbl_properties_links.inc.php: bug #1560152, after renaming a table the navigation does not work 2006-09-22 Sebastian Mendel diff --git a/libraries/tbl_replace_fields.inc.php b/libraries/tbl_replace_fields.inc.php index ba9b68c88..ec3c05378 100644 --- a/libraries/tbl_replace_fields.inc.php +++ b/libraries/tbl_replace_fields.inc.php @@ -1,226 +1,221 @@ diff --git a/tbl_change.php b/tbl_change.php index 326b4ce44..8afe8115e 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -1,6 +1,8 @@ $primary_key) { + foreach ($primary_key_array as $rowcount => $primary_key) { $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';'; $result[$rowcount] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE); $row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]); @@ -221,19 +223,19 @@ document.onkeydown = onKeyDownArrowsHandler;
> - + - - + + - + ' . $strFunction . '' . "\n"; } -foreach ($loop_array AS $vrowcount => $vrow) { +foreach ($loop_array as $vrowcount => $vrow) { if ($vrow === FALSE) { unset($vrow); } @@ -311,8 +313,8 @@ foreach ($loop_array AS $vrowcount => $vrow) { $jsvkey = $vrowcount; $browse_foreigners_uri = '&pk=' . $vrowcount; } else { - $jsvkey = urlencode($primary_keys[$vrowcount]); - $browse_foreigners_uri = '&pk=' . urlencode($primary_keys[$vrowcount]); + $jsvkey = htmlspecialchars(trim($primary_keys[$vrowcount])); + $browse_foreigners_uri = '&pk=' . urlencode(trim($primary_keys[$vrowcount])); } $vkey = '[multi_edit][' . $jsvkey . ']'; @@ -365,7 +367,8 @@ foreach ($loop_array AS $vrowcount => $vrow) { $row_table_def = $trow_table_def[$i]; $row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']); - $field = $row_table_def['Field']; + $field = $row_table_def['Field']; + $field_html = $field; // removed previous PHP3-workaround that caused a problem with // field names like '000' @@ -415,7 +418,7 @@ foreach ($loop_array AS $vrowcount => $vrow) { : PMA_DBI_field_len($vresult, $i); $first_timestamp = 0; - $field_name = htmlspecialchars($field); + $field_name = $field_html; if (isset($comments_map[$field])) { $field_name = '' . $field_name . ''; } @@ -486,7 +489,7 @@ foreach ($loop_array AS $vrowcount => $vrow) { // it's better to set a fields_prev in this situation $backup_field = (PMA_MYSQL_INT_VERSION < 40100 && $row_table_def['True_Type'] == 'timestamp') ? '' - : ''; + : ''; } else { // loic1: display default values if (!isset($row_table_def['Default'])) { @@ -519,7 +522,7 @@ foreach ($loop_array AS $vrowcount => $vrow) { } else { ?> - ="return unNullify('', '')" tabindex="" id="field__1"> $vrow) { // --------------- echo ' ' . "\n"; if ($row_table_def['Null'] == 'YES') { - echo ' $vrow) { if (!(($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary)) ) { echo ' $vrow) { } else { $onclick .= '5, '; } - $onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\', \'' . $vkey . '\'); this.checked = true}; return true" />' . "\n"; + $onclick .= '\'' . $field_html . '\', \'' . md5($field) . '\', \'' . $vkey . '\'); this.checked = true}; return true" />' . "\n"; echo $onclick; } else { - echo ' $vrow) { ?> - - - ="return unNullify('', '')" tabindex="" id="field__3" value="" /> + + + ="return unNullify('', '')" tabindex="" id="field__3" value="" /> @@ -662,9 +669,9 @@ foreach ($loop_array AS $vrowcount => $vrow) { ?> - - - + + @@ -677,16 +684,16 @@ foreach ($loop_array AS $vrowcount => $vrow) { - + - + $vrow) { $enum_cnt = count($enum); ?> - - + + $vrow) { if (strlen($row_table_def['Type']) > 20) { echo "\n"; ?> - ="return unNullify('', '')" tabindex="" id="field__3"> $vrow) { $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j])); echo ' '; //echo '' . "\n"; echo $files; echo ' ' . "\n"; @@ -898,21 +905,21 @@ foreach ($loop_array AS $vrowcount => $vrow) { if ($is_char && ($cfg['CharEditing'] == 'textarea' || strpos($data, "\n") !== FALSE)) { echo "\n"; ?> - + - ="return unNullify('', '')" tabindex="" id="field__3" /> + ="return unNullify('', '')" tabindex="" id="field__3" /> - + - + ', $pk) + . ' LIMIT 1;'; + $res = PMA_DBI_query($local_query); + $row = PMA_DBI_fetch_row($res); + $meta = PMA_DBI_get_fields_meta($res); + $url_params['primary_key'][] = PMA_getUvaCondition($res, count($row), $meta, $row); + } } } -} elseif (isset($after_insert) && $after_insert == 'edit_next') { - $goto = 'tbl_change.php?' - . PMA_generate_common_url($db, $table, '&') - . '&goto=' . urlencode($goto) - . '&pos=' . $pos - . '&session_max_rows=' . $session_max_rows - . '&disp_direction=' . $disp_direction - . '&repeat_cells=' . $repeat_cells - . '&dontlimitchars=' . $dontlimitchars - . '&after_insert=' . $after_insert - . (empty($sql_query) ? '' : '&sql_query=' . urlencode($sql_query)); - if (isset($primary_key)) { - foreach ($primary_key AS $pk) { - $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . str_replace('` =', '` >', urldecode($pk)) . ' LIMIT 1;'; - $res = PMA_DBI_query($local_query); - $row = PMA_DBI_fetch_row($res); - $meta = PMA_DBI_get_fields_meta($res); - $goto .= '&primary_key[]=' . urlencode(PMA_getUniqueCondition($res, count($row), $meta, $row)); - } - } -} elseif ($goto == 'sql.php') { - $goto = 'sql.php?' - . PMA_generate_common_url($db, $table, '&') - . '&pos=' . $pos - . '&session_max_rows=' . $session_max_rows - . '&disp_direction=' . $disp_direction - . '&repeat_cells=' . $repeat_cells - . '&dontlimitchars=' . $dontlimitchars - . '&sql_query=' . urlencode($sql_query); -} elseif (!empty($goto)) { - // Security checkings - $is_gotofile = preg_replace('@^([^?]+).*$@', '\\1', $goto); - if (!@file_exists('./' . $is_gotofile)) { - $goto = (! isset($table) || ! strlen($table)) ? 'db_sql.php' : 'tbl_sql.php'; - $is_gotofile = TRUE; +} elseif (! empty($GLOBALS['goto'])) { + if (! preg_match('@^[a-z_]+\.php$@', $GLOBALS['goto'])) { + // this should NOT happen + //$GLOBALS['goto'] = false; + $goto_include = false; } else { - $is_gotofile = ($is_gotofile == $goto); + $goto_include = $GLOBALS['goto']; + } + if ($GLOBALS['goto'] == 'db_sql.php' && isset($GLOBALS['table'])) { + unset($GLOBALS['table']); + } +} + +if (! $goto_include) { + if (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) { + $goto_include = 'db_sql.php'; + } else { + $goto_include = 'tbl_sql.php'; } } // Defines the url to return in case of failure of the query -if (isset($err_url)) { - $err_url = urldecode($err_url); +if (isset($_REQUEST['err_url'])) { + $err_url = $_REQUEST['err_url']; } else { - $err_url = str_replace('&', '&', $goto) - . (empty($primary_key) ? '' : '&primary_key=' . (is_array($primary_key) ? $primary_key[0] : $primary_key)); + $err_url = 'tbl_change.php' . PMA_generate_common_url($url_params); } // Misc -$seen_binary = FALSE; +$seen_binary = false; /** * Prepares the update/insert of a row */ -if (isset($primary_key)) { +if (isset($_REQUEST['primary_key'])) { // we were editing something => use primary key - $loop_array = (is_array($primary_key) ? $primary_key : array(0 => $primary_key)); - $using_key = TRUE; - $is_insert = ($submit_type == $strInsertAsNewRow); + $loop_array = (is_array($_REQUEST['primary_key']) ? $_REQUEST['primary_key'] : array($_REQUEST['primary_key'])); + $using_key = true; + $is_insert = ($_REQUEST['submit_type'] == $GLOBALS['strInsertAsNewRow']); } else { // new row => use indexes $loop_array = array(); - for ($i = 0; $i < $cfg['InsertRows']; $i++) $loop_array[$i] = $i; - $using_key = FALSE; - $is_insert = TRUE; + foreach ($_REQUEST['fields']['multi_edit'] as $key => $dummy) { + $loop_array[] = $key; + } + $using_key = false; + $is_insert = true; } $query = array(); $message = ''; +$value_sets = array(); +$func_no_param = array( + 'NOW', + 'CURDATE', + 'CURTIME', + 'UTC_DATE', + 'UTC_TIME', + 'UTC_TIMESTAMP', + 'UNIX_TIMESTAMP', + 'RAND', + 'USER', + 'LAST_INSERT_ID', +); -foreach ($loop_array AS $primary_key_index => $enc_primary_key) { +foreach ($loop_array as $primary_key) { // skip fields to be ignored - if (!$using_key && isset($GLOBALS['insert_ignore_' . $enc_primary_key])) { + if (! $using_key && isset($_REQUEST['insert_ignore_' . $primary_key])) { continue; } - // Restore the "primary key" to a convenient format - $primary_key = urldecode($enc_primary_key); - // Defines the SET part of the sql query - $valuelist = ''; - $fieldlist = ''; + $query_values = array(); // Map multi-edit keys to single-level arrays, dependent on how we got the fields - $me_fields = isset($fields['multi_edit']) && isset($fields['multi_edit'][$enc_primary_key]) ? $fields['multi_edit'][$enc_primary_key] : null; - $me_fields_prev = isset($fields_prev['multi_edit']) && isset($fields_prev['multi_edit'][$enc_primary_key]) ? $fields_prev['multi_edit'][$enc_primary_key] : null; - $me_funcs = isset($funcs['multi_edit']) && isset($funcs['multi_edit'][$enc_primary_key]) ? $funcs['multi_edit'][$enc_primary_key] : null; - $me_fields_type = isset($fields_type['multi_edit']) && isset($fields_type['multi_edit'][$enc_primary_key]) ? $fields_type['multi_edit'][$enc_primary_key] : null; - $me_fields_null = isset($fields_null['multi_edit']) && isset($fields_null['multi_edit'][$enc_primary_key]) ? $fields_null['multi_edit'][$enc_primary_key] : null; - $me_fields_null_prev = isset($fields_null_prev['multi_edit']) && isset($fields_null_prev['multi_edit'][$enc_primary_key]) ? $fields_null_prev['multi_edit'][$enc_primary_key] : null; - $me_auto_increment = isset($auto_increment['multi_edit']) && isset($auto_increment['multi_edit'][$enc_primary_key]) ? $auto_increment['multi_edit'][$enc_primary_key] : null; + $me_fields = + isset($_REQUEST['fields']['multi_edit'][$primary_key]) + ? $_REQUEST['fields']['multi_edit'][$primary_key] + : array(); + $me_fields_prev = + isset($_REQUEST['fields_prev']['multi_edit'][$primary_key]) + ? $_REQUEST['fields_prev']['multi_edit'][$primary_key] + : null; + $me_funcs = + isset($_REQUEST['funcs']['multi_edit'][$primary_key]) + ? $_REQUEST['funcs']['multi_edit'][$primary_key] + : null; + $me_fields_type = + isset($_REQUEST['fields_type']['multi_edit'][$primary_key]) + ? $_REQUEST['fields_type']['multi_edit'][$primary_key] + : null; + $me_fields_null = + isset($_REQUEST['fields_null']['multi_edit'][$primary_key]) + ? $_REQUEST['fields_null']['multi_edit'][$primary_key] + : null; + $me_fields_null_prev = + isset($_REQUEST['fields_null_prev']['multi_edit'][$primary_key]) + ? $_REQUEST['fields_null_prev']['multi_edit'][$primary_key] + : null; + $me_auto_increment = + isset($_REQUEST['auto_increment']['multi_edit'][$primary_key]) + ? $_REQUEST['auto_increment']['multi_edit'][$primary_key] + : null; - if ($using_key && isset($me_fields_type) && is_array($me_fields_type) && isset($primary_key)) { - $prot_result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';'); - $prot_row = PMA_DBI_fetch_assoc($prot_result); - PMA_DBI_free_result($prot_result); - unset($prot_result); - } + foreach ($me_fields as $key => $val) { - foreach ($me_fields AS $encoded_key => $val) { - $key = urldecode($encoded_key); - $fieldlist .= PMA_backquote($key) . ', '; + require './libraries/tbl_replace_fields.inc.php'; - require('./libraries/tbl_replace_fields.inc.php'); - - if (empty($me_funcs[$encoded_key])) { - $cur_value = $val . ', '; - } elseif (preg_match('@^(UNIX_TIMESTAMP)$@', $me_funcs[$encoded_key]) && $val != '\'\'') { - $cur_value = $me_funcs[$encoded_key] . '(' . $val . '), '; - } elseif (preg_match('@^(NOW|CURDATE|CURTIME|UTC_DATE|UTC_TIME|UTC_TIMESTAMP|UNIX_TIMESTAMP|RAND|USER|LAST_INSERT_ID)$@', $me_funcs[$encoded_key])) { - $cur_value = $me_funcs[$encoded_key] . '(), '; + if (empty($me_funcs[$key])) { + $cur_value = $val; + } elseif ('UNIX_TIMESTAMP' === $me_funcs[$key] && $val != "''") { + $cur_value = $me_funcs[$key] . '(' . $val . ')'; + } elseif (in_array($me_funcs[$key], $func_no_param)) { + $cur_value = $me_funcs[$key] . '()'; } else { - $cur_value = $me_funcs[$encoded_key] . '(' . $val . '), '; + $cur_value = $me_funcs[$key] . '(' . $val . ')'; } // i n s e r t if ($is_insert) { // no need to add column into the valuelist - $valuelist .= $cur_value; + $query_values[] = $cur_value; // u p d a t e - } elseif (isset($me_fields_null_prev) && isset($me_fields_null_prev[$encoded_key]) && !empty($me_fields_null_prev[$encoded_key]) && !isset($me_fields_null[$encoded_key])) { + } elseif (!empty($me_fields_null_prev[$key]) + && !isset($me_fields_null[$key])) { // field had the null checkbox before the update // field no longer has the null checkbox - $valuelist .= PMA_backquote($key) . ' = ' . $cur_value; - } elseif (empty($me_funcs[$encoded_key]) - && isset($me_fields_prev) && isset($me_fields_prev[$encoded_key]) - && ("'" . PMA_sqlAddslashes(urldecode($me_fields_prev[$encoded_key])) . "'" == $val)) { + $query_values[] = PMA_backquote($key) . ' = ' . $cur_value; + } elseif (empty($me_funcs[$key]) + && isset($me_fields_prev[$key]) + && ("'" . PMA_sqlAddslashes($me_fields_prev[$key]) . "'" == $val)) { // No change for this column and no MySQL function is used -> next column continue; - } elseif (!empty($val)) { + } elseif (! empty($val)) { // avoid setting a field to NULL when it's already NULL // (field had the null checkbox before the update // field still has the null checkbox) - if (!(isset($me_fields_null_prev) && isset($me_fields_null_prev[$encoded_key]) && !empty($me_fields_null_prev[$encoded_key]) && isset($me_fields_null[$encoded_key]))) { - $valuelist .= PMA_backquote($key) . ' = ' . $cur_value; + if (!(! empty($me_fields_null_prev[$key]) + && isset($me_fields_null[$key]))) { + $query_values[] = PMA_backquote($key) . ' = ' . $cur_value; } } - } // end while + } // end foreach ($me_fields as $key => $val) - // get rid of last , - $valuelist = preg_replace('@, $@', '', $valuelist); + if (count($query_values) > 0) { + if ($is_insert) { + $value_sets[] = implode(', ', $query_values); + } else { + // build update query + $query[] = 'UPDATE ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($GLOBALS['table']) + . ' SET ' . implode(', ', $query_values) . ' WHERE ' . $primary_key . ' LIMIT 1'; - // Builds the sql query - if ($is_insert) { - if (empty($query)) { - // first inserted row -> prepare template - $fieldlist = preg_replace('@, $@', '', $fieldlist); - $query = array('INSERT INTO ' . PMA_backquote($table) . ' (' . $fieldlist . ') VALUES '); } - // append current values - $query[0] .= '(' . $valuelist . '), '; - $message = $strInsertedRows . ' '; - } elseif (!empty($valuelist)) { - // build update query - $query[] = 'UPDATE ' . PMA_backquote($table) . ' SET ' . $valuelist . ' WHERE' . $primary_key . ' LIMIT 1'; - - $message = $strAffectedRows . ' '; } -} // end for +} // end foreach ($loop_array as $primary_key) +unset($me_fields_prev, $me_funcs, $me_fields_type, $me_fields_null, $me_fields_null_prev, + $me_auto_increment, $cur_value, $key, $val, $loop_array, $primary_key, $using_key, + $func_no_param); -// trim last , from insert query -if ($is_insert) { - $query[0] = preg_replace('@, $@', '', $query[0]); -} -if (empty($valuelist) && empty($query)) { +// Builds the sql query +if ($is_insert && count($value_sets) > 0) { + // first inserted row -> prepare template + foreach ($me_fields as $key => $val) { + $query_fields[] = PMA_backquote($key); + } + $query[] = 'INSERT INTO ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($GLOBALS['table']) + . ' (' . implode(', ', $query_fields) . ') VALUES (' . implode('), (', $value_sets) . ')'; + + unset($query_fields, $value_sets); + + $message = $GLOBALS['strInsertedRows'] . ' '; +} elseif (! empty($query)) { + $message = $GLOBALS['strAffectedRows'] . ' '; +} else { // No change -> move back to the calling script - $message = $strNoModification; - if ($is_gotofile) { - $js_to_run = 'functions.js'; - require_once('./libraries/header.inc.php'); - require('./' . PMA_securePath($goto)); - } else { - PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . $goto . '&disp_message=' . urlencode($message) . '&disp_query='); - - } - exit(); + $message = $GLOBALS['strNoModification']; + $js_to_run = 'functions.js'; + $active_page = $goto_include; + require_once './libraries/header.inc.php'; + require './' . PMA_securePath($goto_include); + exit; } +unset($me_fields, $is_insert); /** * Executes the sql query and get the result, then move back to the calling * page */ -$sql_query = implode(';', $query) . ';'; +if (! empty($GLOBALS['sql_query'])) { + $url_params['sql_query'] = $GLOBALS['sql_query']; + $return_to_sql_query = $GLOBALS['sql_query']; +} +$GLOBALS['sql_query'] = implode('; ', $query) . ';'; $total_affected_rows = 0; $last_message = ''; $warning_message = ''; -foreach ($query AS $query_index => $single_query) { - if ($cfg['IgnoreMultiSubmitErrors']) { +foreach ($query as $single_query) { + if ($GLOBALS['cfg']['IgnoreMultiSubmitErrors']) { $result = PMA_DBI_try_query($single_query); } else { $result = PMA_DBI_query($single_query); @@ -251,7 +311,7 @@ foreach ($query AS $query_index => $single_query) { if (isset($GLOBALS['warning'])) { $warning_message .= $GLOBALS['warning'] . '[br]'; } - if (!$result) { + if (! $result) { $message .= PMA_DBI_getError(); } else { if (@PMA_DBI_affected_rows()) { @@ -260,44 +320,41 @@ foreach ($query AS $query_index => $single_query) { $insert_id = PMA_DBI_insert_id(); if ($insert_id != 0) { - $last_message .= '[br]'.$strInsertedRowId . ' ' . $insert_id; + // insert_id is id of FIRST record inserted in one insert, so if we + // inserted multiple rows, we had to increment this + + if ($total_affected_rows > 0) { + $insert_id = $insert_id + $total_affected_rows - 1; + } + $last_message .= '[br]' . $GLOBALS['strInsertedRowId'] . ' ' . $insert_id; } + PMA_DBI_free_result($result); } // end if - PMA_DBI_free_result($result); unset($result); } +unset($single_query, $query); -if ($total_affected_rows != 0) { - $message .= $total_affected_rows; -} else { - $message .= $strModifications; -} +$message .= $total_affected_rows . $last_message; -$message .= $last_message; - -if (!empty($warning_message)) { +if (! empty($warning_message)) { /** - * @todo use a
in PMA_showMessage() for this part of the message + * @todo use a
in PMA_showMessage() for this part of + * the message */ $message .= '[br]' . $warning_message; } +unset($warning_message, $total_affected_rows, $last_message); -if ($is_gotofile) { - if ($goto == 'db_sql.php' && isset($table)) { - unset($table); - } - $js_to_run = 'functions.js'; - $active_page = $goto; - require_once('./libraries/header.inc.php'); - require('./' . PMA_securePath($goto)); -} else { - - // if we have seen binary, - // we do not append the query to the Location so it won't be displayed - // on the resulting page - // Nijel: we also need to limit size of url... - $add_query = (!$seen_binary && strlen($sql_query) < 1024 ? '&disp_query=' . urlencode($sql_query) : ''); - PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . $goto . '&disp_message=' . urlencode($message) . $add_query); +if (isset($return_to_sql_query)) { + $disp_query = $GLOBALS['sql_query']; + $disp_message = $message; + unset($message); + $GLOBALS['sql_query'] = $return_to_sql_query; } -exit(); + +$js_to_run = 'functions.js'; +$active_page = $goto_include; +require_once './libraries/header.inc.php'; +require './' . PMA_securePath($goto_include); +exit; ?>