diff --git a/ChangeLog b/ChangeLog index 4336f3539..318f91a13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ $Id$ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyAdmin/ChangeLog $ 2.11.7.0 (not yet released) +- bug #1908719 [interface] New field cannot be auto-increment and primary key 2.11.6.0 (not yet released) - bug #1903724 [interface] Displaying of very large queries in error message diff --git a/libraries/Table.class.php b/libraries/Table.class.php index 7122733e3..066d4a735 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -345,19 +345,29 @@ class PMA_Table { $query .= ' ' . $extra; // Force an auto_increment field to be part of the primary key // even if user did not tick the PK box; - // but the PK could contain other columns so do not append - // a PRIMARY KEY clause, just add a member to $field_primary if ($extra == 'AUTO_INCREMENT') { $primary_cnt = count($field_primary); - $found_in_pk = false; - for ($j = 0; $j < $primary_cnt; $j++) { - if ($field_primary[$j] == $index) { - $found_in_pk = true; - break; + if (1 == $primary_cnt) { + for ($j = 0; $j < $primary_cnt && $field_primary[$j] != $index; $j++) { + //void + } + if (isset($field_primary[$j]) && $field_primary[$j] == $index) { + $query .= ' PRIMARY KEY'; + unset($field_primary[$j]); + } + // but the PK could contain other columns so do not append + // a PRIMARY KEY clause, just add a member to $field_primary + } else { + $found_in_pk = false; + for ($j = 0; $j < $primary_cnt; $j++) { + if ($field_primary[$j] == $index) { + $found_in_pk = true; + break; + } + } // end for + if (! $found_in_pk) { + $field_primary[] = $index; } - } // end for - if (! $found_in_pk) { - $field_primary[] = $index; } } // end if (auto_increment) }