diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index b3d929da99..2495e16db3 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -1332,18 +1332,28 @@ class ExportSql extends ExportPlugin for ($k = 0; $k < $sql_count; $k++) { if (preg_match( - '@[\s]+(AUTO_INCREMENT )@', + '( AUTO_INCREMENT | AUTO_INCREMENT,| AUTO_INCREMENT$)', $sql_lines[$k] )) { //removes extra space at the beginning, if there is $sql_lines[$k] = ltrim($sql_lines[$k], ' '); - //backup auto increment code before remove + //creates auto increment code $sql_auto_increments .= "MODIFY " . $sql_lines[$k]; - //removes auto increments from table creation + //removes auto increment code from table definition $sql_lines[$k] = str_replace( " AUTO_INCREMENT", "", $sql_lines[$k] ); } + if (preg_match( + '@[\s]+(AUTO_INCREMENT=)@', + $sql_lines[$k] + )) { + //adds auto increment value + $increment_value = substr($sql_lines[$k], strpos($sql_lines[$k],"AUTO_INCREMENT")); + $increment_value_array = explode( ' ', $increment_value); + $sql_auto_increments .= $increment_value_array[0].";"; + + } } if ($sql_auto_increments != '') {