bug #1339184, MySQL 5 strict mode, errors inserting auto-increment fields

This commit is contained in:
Marc Delisle
2005-11-03 18:24:15 +00:00
parent fb923f851a
commit 91870dadbe
4 changed files with 17 additions and 3 deletions

View File

@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
$Id$
$Source$
2005-11-03 Marc Delisle <lem9@users.sourceforge.net>
* tbl_change.php, tbl_replace.php, tbl_replace_fields.php:
bug #1339184, problems in strict mode inserting auto-increment fields
2005-11-03 Michal Čihař <michal@cihar.com>
* libraries/common.lib.php: Incorrect message for validate links (bug
#1346608).

View File

@@ -838,6 +838,11 @@ foreach ($loop_array AS $vrowcount => $vrow) {
?>
<input type="text" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>" maxlength="<?php echo $maxlength; ?>" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" id="field_<?php echo ($idindex); ?>_3" />
<?php
if ($row_table_def['Extra'] == 'auto_increment') {
?>
<input type="hidden" name="auto_increment<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="1" />
<?php
} // end if
if ($type == 'date' || $type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
?>
<script type="text/javascript">

View File

@@ -2,7 +2,6 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* Gets some core libraries
*/
@@ -136,6 +135,7 @@ foreach ($loop_array AS $primary_key_index => $enc_primary_key) {
$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_auto_increment = isset($auto_increment['multi_edit']) && isset($auto_increment['multi_edit'][$enc_primary_key]) ? $auto_increment['multi_edit'][$enc_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 . ';');

View File

@@ -114,7 +114,7 @@ if (!$check_stop) {
if (isset($me_fields_type[$encoded_key])) $type = $me_fields_type[$encoded_key];
else $type = '';
$f = 'field_' . md5($key);
$t_fval = (isset($$f) ? $$f : null);
@@ -191,7 +191,12 @@ if (!$check_stop) {
break;
default:
$val = "'" . PMA_sqlAddslashes($val) . "'";
// best way to avoid problems in strict mode (works also in non-strict mode)
if (isset($me_auto_increment) && isset($me_auto_increment[$encoded_key])) {
$val = 'NULL';
} else {
$val = "'" . PMA_sqlAddslashes($val) . "'";
}
break;
}
break;