1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-09 16:17:48 +02:00

Support importing table data

Signed-off-by: Takashi SHIRAI <shirai@nintendo.co.jp>
This commit is contained in:
Takashi SHIRAI
2019-03-26 13:18:34 +09:00
committed by Jakub Vrana
parent 53a8496412
commit 339981b9d6
2 changed files with 20 additions and 0 deletions

View File

@@ -141,6 +141,25 @@ if (isset($_GET["oracle"])) {
return true; // automatic start
}
function insertUpdate($table, $rows, $primary) {
global $connection;
foreach ($rows as $set) {
$update = array();
$where = array();
foreach ($set as $key => $val) {
$update[] = "$key = $val";
if (isset($primary[idf_unescape($key)])) {
$where[] = "$key = $val";
}
}
if (!(($where && queries("UPDATE " . table($table) . " SET " . implode(", ", $update) . " WHERE " . implode(" AND ", $where)) && $connection->affected_rows)
|| queries("INSERT INTO " . table($table) . " (" . implode(", ", array_keys($set)) . ") VALUES (" . implode(", ", $set) . ")")
)) {
return false;
}
}
return true;
}
}