]> git.joonet.de Git - adminer.git/commitdiff
Allow disabling auto_increment value export
authorJakub Vrana <jakub@vrana.cz>
Thu, 3 Jun 2010 12:15:23 +0000 (14:15 +0200)
committerJakub Vrana <jakub@vrana.cz>
Thu, 3 Jun 2010 12:15:23 +0000 (14:15 +0200)
adminer/drivers/mysql.inc.php
adminer/drivers/sqlite.inc.php
adminer/dump.inc.php
adminer/include/export.inc.php
changes.txt

index 1ee22deb0ca54299a2f764bfaa119f451469ce73..4e8b6c38e4fa2f12d19c7e53e4b98d705e0b7744 100644 (file)
@@ -828,11 +828,16 @@ if (!defined("DRIVER")) {
        
        /** 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
index f684957628efe8966ed3dc12f7423d9f726ed79b..86a6fa1f7fe5dcd44ecd5af9759e9826f849b02d 100644 (file)
@@ -521,9 +521,12 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                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) {
index 75c094b7b91df048d1072f16eb4dce5a21915613..53acc0919d517f88806739737dd0de41fb812e16 100644 (file)
@@ -175,6 +175,7 @@ echo ($jush == "sqlite" ? "" : "<tr><th>" . lang('Database') . "<td>" . html_sel
        . (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"]);
index 7c4495290946c8ca9b11161e13aeb913940aaf37..74d6c8b423b86907f4dbdde9c05a4a7a2efdbebb 100644 (file)
@@ -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";
index 97d4c43df2c93d5fbbdbc0dab694440f0a2668f5..68d45259df2313bb0e02c6846d21f3fd8738f638 100644 (file)
@@ -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)