mirror of
https://github.com/vrana/adminer.git
synced 2025-08-07 15:16:44 +02:00
PostgreSQL: Fix clone after e395fe5
This commit is contained in:
@@ -239,11 +239,11 @@ if (isset($_GET["pgsql"])) {
|
||||
$this->types[lang('User types')] = array_flip($types);
|
||||
}
|
||||
|
||||
function insertSql($table, $set) {
|
||||
function insertReturning($table) {
|
||||
$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)) : "");
|
||||
return (count($auto_increment) == 1 ? " RETURNING " . idf_escape(key($auto_increment)) : "");
|
||||
}
|
||||
|
||||
function insertUpdate($table, $rows, $primary) {
|
||||
@@ -783,7 +783,7 @@ ORDER BY SPECIFIC_NAME');
|
||||
}
|
||||
|
||||
function last_id($result) {
|
||||
return (is_object($result) ? $result->fetch_column(0) : 0);
|
||||
return (is_object($result) && $result->num_rows ? $result->fetch_column(0) : 0);
|
||||
}
|
||||
|
||||
function explain($connection, $query) {
|
||||
|
@@ -139,19 +139,18 @@ abstract class SqlDriver {
|
||||
* @return bool
|
||||
*/
|
||||
function insert($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
|
||||
return queries("INSERT INTO " . table($table) . ($set
|
||||
? " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")"
|
||||
: " DEFAULT VALUES"
|
||||
);
|
||||
) . $this->insertReturning($table));
|
||||
}
|
||||
|
||||
/** Get RETURNING clause for INSERT queries, PostgreSQL specific
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function insertReturning($table) {
|
||||
return "";
|
||||
}
|
||||
|
||||
/** Insert or update data in table
|
||||
|
@@ -125,7 +125,7 @@ if ($_POST && !$error) {
|
||||
$result = ($_POST["delete"]
|
||||
? $driver->delete($TABLE, $where_check)
|
||||
: ($_POST["clone"]
|
||||
? queries("INSERT $query$where_check")
|
||||
? queries("INSERT $query$where_check" . $driver->insertReturning($TABLE))
|
||||
: $driver->update($TABLE, $set, $where_check)
|
||||
)
|
||||
);
|
||||
|
Reference in New Issue
Block a user