Permalink
Browse files

Allow disabling auto_increment value export

  • Loading branch information...
1 parent 38ad832 commit fe53964c5fca7a3026da980aa3fbd4bbae076e3f @vrana committed Jun 3, 2010
Showing with 15 additions and 5 deletions.
  1. +7 −2 adminer/drivers/mysql.inc.php
  2. +5 −2 adminer/drivers/sqlite.inc.php
  3. +1 −0 adminer/dump.inc.php
  4. +1 −1 adminer/include/export.inc.php
  5. +1 −0 changes.txt
@@ -828,11 +828,16 @@ function set_schema($schema) {
/** Get SQL command to create table
* @param string
+ * @param bool
* @return string
*/
- function create_sql($table) {
+ function create_sql($table, $auto_increment) {
global $connection;
- return $connection->result("SHOW CREATE TABLE " . table($table), 1);
+ $return = $connection->result("SHOW CREATE TABLE " . table($table), 1);
+ if (!$auto_increment) {
+ $return = preg_replace('~ AUTO_INCREMENT=[0-9]+~', '', $return); //! skip comments
+ }
+ return $return;
}
/** Get SQL command to truncate table
@@ -521,9 +521,12 @@ function set_schema($scheme) {
return true;
}
- function create_sql($table) {
+ function create_sql($table, $auto_increment) {
global $connection;
- return $connection->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . $connection->quote($table));
+ return ($auto_increment || $table != "sqlite_sequence" //! remove also INSERT
+ ? $connection->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . $connection->quote($table))
+ : ""
+ );
}
function truncate_sql($table) {
@@ -175,6 +175,7 @@
. (support("event") ? checkbox("events", 1, $checked, lang('Events')) : "")
);
echo "<tr><th>" . lang('Tables') . "<td>" . html_select('table_style', $table_style, $row["table_style"])
+ . checkbox("auto_increment", 1, $row["table_style"], lang('Auto Increment'))
. (support("trigger") ? checkbox("triggers", 1, $row["table_style"], lang('Triggers')) : "")
;
echo "<tr><th>" . lang('Data') . "<td>" . html_select('data_style', $data_style, $row["data_style"]);
@@ -17,7 +17,7 @@ function dump_table($table, $style, $is_view = false) {
dump_csv(array_keys(fields($table)));
}
} elseif ($style) {
- $create = create_sql($table);
+ $create = create_sql($table, $_POST["auto_increment"]);
if ($create) {
if ($style == "DROP+CREATE") {
echo "DROP " . ($is_view ? "VIEW" : "TABLE") . " IF EXISTS " . table($table) . ";\n";
View
@@ -12,6 +12,7 @@ Schemas, sequences and types support (PostgreSQL)
Autofocus username in login form
Disable spellchecking in SQL textareas
Display auto_increment value of inserted item
+Allow disabling auto_increment value export
Link table names in SQL queries
Japanese translation
Defer table information in database overview to JavaScript (performance)

0 comments on commit fe53964

Please sign in to comment.