mirror of
https://github.com/vrana/adminer.git
synced 2025-08-12 09:34:10 +02:00
Use REPLACE in CSV import
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1045 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -90,7 +90,8 @@ if ($_POST && !$error) {
|
|||||||
$affected = 0;
|
$affected = 0;
|
||||||
$length = 0;
|
$length = 0;
|
||||||
$result = true;
|
$result = true;
|
||||||
$query = "INSERT INTO " . idf_escape($_GET["select"]);
|
$dbh->query("SET foreign_key_checks = 0");
|
||||||
|
$query = "REPLACE " . idf_escape($_GET["select"]); // ON DUPLICATE KEY UPDATE would require one query per record
|
||||||
$packet_size = $dbh->result($dbh->query("SELECT @@max_allowed_packet"));
|
$packet_size = $dbh->result($dbh->query("SELECT @@max_allowed_packet"));
|
||||||
$rows = array();
|
$rows = array();
|
||||||
preg_match_all('~("[^"]*"|[^"\\n])+~', $file, $matches);
|
preg_match_all('~("[^"]*"|[^"\\n])+~', $file, $matches);
|
||||||
@@ -111,7 +112,7 @@ if ($_POST && !$error) {
|
|||||||
if (!$result) {
|
if (!$result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$affected += $dbh->affected_rows;
|
$affected += count($rows);
|
||||||
$length = strlen($query);
|
$length = strlen($query);
|
||||||
$rows = array();
|
$rows = array();
|
||||||
}
|
}
|
||||||
@@ -124,7 +125,7 @@ if ($_POST && !$error) {
|
|||||||
}
|
}
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$result = queries($query . implode(",", $rows));
|
$result = queries($query . implode(",", $rows));
|
||||||
$affected += $dbh->affected_rows;
|
$affected += count($rows);
|
||||||
}
|
}
|
||||||
query_redirect(queries(), remove_from_uri("page"), lang('%d row(s) have been imported.', $affected), $result, false, !$result);
|
query_redirect(queries(), remove_from_uri("page"), lang('%d row(s) have been imported.', $affected), $result, false, !$result);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user