1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-24 23:16:15 +02:00

Generalize transactions

This commit is contained in:
Jakub Vrana
2013-07-09 11:43:01 -07:00
parent 56b0917acd
commit 7a1133a2fd
7 changed files with 38 additions and 22 deletions

View File

@@ -173,7 +173,7 @@ if ($_POST && !$error) {
$cols = array_keys($fields);
preg_match_all('~(?>"[^"]*"|[^"\\r\\n]+)+~', $file, $matches);
$affected = count($matches[0]);
begin();
$driver->begin();
$separator = ($_POST["separator"] == "csv" ? "," : ($_POST["separator"] == "tsv" ? "\t" : ";"));
$rows = array();
foreach ($matches[0] as $key => $val) {
@@ -192,10 +192,10 @@ if ($_POST && !$error) {
}
$result = (!$rows || $driver->insertUpdate($TABLE, $rows, $primary));
if ($result) {
queries("COMMIT");
$driver->commit();
}
queries_redirect(remove_from_uri("page"), lang('%d row(s) have been imported.', $affected), $result);
queries("ROLLBACK"); // after queries_redirect() to not overwrite error
$driver->rollback(); // after queries_redirect() to not overwrite error
}
}