mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 07:36:44 +02:00
PostgreSQL: Display auto_increment of inserted rows
This commit is contained in:
@@ -241,6 +241,13 @@ if (isset($_GET["pgsql"])) {
|
|||||||
$this->types[lang('User types')] = array_flip($types);
|
$this->types[lang('User types')] = array_flip($types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function insertSql($table, $set) {
|
||||||
|
$auto_increment = array_filter(fields($table), function ($field) {
|
||||||
|
return $field['auto_increment'];
|
||||||
|
});
|
||||||
|
return parent::insertSql($table, $set) . (count($auto_increment) == 1 ? " RETURNING " . idf_escape(key($auto_increment)) : "");
|
||||||
|
}
|
||||||
|
|
||||||
function insertUpdate($table, $rows, $primary) {
|
function insertUpdate($table, $rows, $primary) {
|
||||||
global $connection;
|
global $connection;
|
||||||
foreach ($rows as $set) {
|
foreach ($rows as $set) {
|
||||||
@@ -781,7 +788,7 @@ ORDER BY SPECIFIC_NAME');
|
|||||||
}
|
}
|
||||||
|
|
||||||
function last_id($result) {
|
function last_id($result) {
|
||||||
return 0; // there can be several sequences
|
return (is_object($result) ? $result->fetch_column(0) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function explain($connection, $query) {
|
function explain($connection, $query) {
|
||||||
|
@@ -139,10 +139,19 @@ abstract class SqlDriver {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function insert($table, $set) {
|
function insert($table, $set) {
|
||||||
return queries("INSERT INTO " . table($table) . ($set
|
return queries($this->insertSql($table, $set));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get SQL query to insert data into table
|
||||||
|
* @param string
|
||||||
|
* @param array same as insert()
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function insertSql($table, $set) {
|
||||||
|
return "INSERT INTO " . table($table) . ($set
|
||||||
? " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")"
|
? " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")"
|
||||||
: " DEFAULT VALUES"
|
: " DEFAULT VALUES"
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Insert or update data in table
|
/** Insert or update data in table
|
||||||
|
@@ -87,6 +87,10 @@ if (extension_loaded('pdo')) {
|
|||||||
return $this->fetch(\PDO::FETCH_NUM);
|
return $this->fetch(\PDO::FETCH_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fetch_column($field) {
|
||||||
|
return $this->fetchColumn($field);
|
||||||
|
}
|
||||||
|
|
||||||
function fetch_field() {
|
function fetch_field() {
|
||||||
$row = (object) $this->getColumnMeta($this->_offset++);
|
$row = (object) $this->getColumnMeta($this->_offset++);
|
||||||
$row->orgtable = $row->table;
|
$row->orgtable = $row->table;
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
Adminer dev:
|
Adminer dev:
|
||||||
|
PostgreSQL: Display auto_increment of inserted rows
|
||||||
|
|
||||||
Adminer 5.0.6 (released 2025-03-17):
|
Adminer 5.0.6 (released 2025-03-17):
|
||||||
Align numbers right (bug #912)
|
Align numbers right (bug #912)
|
||||||
|
Reference in New Issue
Block a user