]> git.joonet.de Git - adminer.git/commitdiff
Display auto_increment value of inserted item
authorJakub Vrana <jakub@vrana.cz>
Wed, 12 May 2010 16:07:46 +0000 (18:07 +0200)
committerJakub Vrana <jakub@vrana.cz>
Wed, 12 May 2010 16:07:46 +0000 (18:07 +0200)
adminer/drivers/mssql.inc.php
adminer/drivers/mysql.inc.php
adminer/drivers/pgsql.inc.php
adminer/drivers/sqlite.inc.php
adminer/edit.inc.php
adminer/lang/cs.inc.php
changes.txt

index 43bb1b0e1e096c4bf845cb5ce37d1659e152c8f0..f7f1f44654c94e37c282f28bd9fad207e68bc1fd 100644 (file)
@@ -409,6 +409,11 @@ WHERE OBJECT_NAME(indexes.object_id) = " . $connection2->quote($table)
                return queries("INSERT INTO " . table($table) . ($set ? " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")" : "DEFAULT VALUES"));
        }
        
+       function last_id() {
+               global $connection;
+               return $connection->result("SELECT SCOPE_IDENTITY()"); // @@IDENTITY can return trigger INSERT
+       }
+       
        function explain($connection, $query) {
                $connection->query("SET SHOWPLAN_ALL ON");
                $return = $connection->query($query);
index c59e51000787afa2423716f867f958a9ee0b91d9..2ff4099a5df3564a035210ff233fbb4e3677f4f3 100644 (file)
@@ -769,6 +769,14 @@ if (!defined("DRIVER")) {
                return queries("INSERT INTO " . table($table) . " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")");
        }
        
+       /** Get last auto increment ID
+       * @return string
+       */
+       function last_id() {
+               global $connection;
+               return $connection->result("SELECT LAST_INSERT_ID()"); // mysql_insert_id() truncates bigint
+       }
+       
        /** Explain select
        * @param Min_DB
        * @param string
index 5af39846a1cda4a098079eaf1ff73f35326d316a..2858db395f9ea009670b1d239adace6794c6298d 100644 (file)
@@ -466,6 +466,10 @@ WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = " . $connection->qu
                return queries("INSERT INTO " . table($table) . ($set ? " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")" : "DEFAULT VALUES"));
        }
        
+       function last_id() {
+               return 0; // there can be several sequences
+       }
+       
        function explain($connection, $query) {
                return $connection->query("EXPLAIN $query");
        }
index 0659e5e23849c13036a203c92a16faf819567614..bafb141e14f86aae15851b753c4e1452e66ffbd3 100644 (file)
@@ -500,6 +500,11 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                return queries("INSERT INTO " . table($table) . ($set ? " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")" : "DEFAULT VALUES"));
        }
        
+       function last_id() {
+               global $connection;
+               return $connection->result("SELECT LAST_INSERT_ROWID()");
+       }
+       
        function explain($connection, $query) {
                return $connection->query("EXPLAIN $query");
        }
index 19a0e1b17df88a07f15f5a27b5205393789c9d12..9a85391286e530cc5dca89082a91d3634dd5715c 100644 (file)
@@ -31,7 +31,9 @@ if ($_POST && !$error && !isset($_GET["select"])) {
                        }
                        query_redirect("UPDATE" . limit1(table($TABLE) . " SET" . implode(",", $set) . "\nWHERE $where"), $location, lang('Item has been updated.'));
                } else {
-                       queries_redirect($location, lang('Item has been inserted.'), insert_into($TABLE, $set));
+                       $result = insert_into($TABLE, $set);
+                       $last_id = ($result ? last_id() : 0);
+                       queries_redirect($location, lang('Item%s has been inserted.', ($last_id ? " $last_id" : "")), $result); //! link
                }
        }
 }
index f1cbc764e7c7c428a6c3e7ebfcd767f40627fbe4..5a534de771e4c3920ef8d1c6817ffa5f7eb6f35f 100644 (file)
@@ -40,7 +40,7 @@ $translations = array(
        'Create new table' => 'Vytvořit novou tabulku',
        'Item has been deleted.' => 'Položka byla smazána.',
        'Item has been updated.' => 'Položka byla aktualizována.',
-       'Item has been inserted.' => 'Položka byla vložena.',
+       'Item%s has been inserted.' => 'Položka%s byla vložena.',
        'Edit' => 'Upravit',
        'Insert' => 'Vložit',
        'Save and insert next' => 'Uložit a vložit další',
index 4cbd56652ab024575900312be440118da9262f88..c7d02cdbb82091be8166dd049805708ab20c33fa 100644 (file)
@@ -9,8 +9,9 @@ Remember export parameters in cookie
 Allow semicolon as CSV separator
 Autofocus username in login form
 Disable spellchecking in SQL textareas
-Japanese translation
+Display auto_increment value of inserted item
 Link table names in SQL queries
+Japanese translation
 Defer table information in database overview to JavaScript (performance)
 Big tables optimizations (performance)