1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-17 20:01:25 +02:00

TSV export and import (bug #3097657)

This commit is contained in:
Jakub Vrana
2010-10-29 18:02:20 +02:00
parent 772f71a780
commit e225d22f97
5 changed files with 8 additions and 7 deletions

View File

@@ -494,7 +494,7 @@ document.getElementById('username').focus();
* @return array
*/
function dumpFormat() {
return array('sql' => 'SQL', 'csv' => 'CSV,', 'csv;' => 'CSV;');
return array('sql' => 'SQL', 'csv' => 'CSV,', 'csv;' => 'CSV;', 'tsv' => 'TSV');
}
/** Export table structure

View File

@@ -697,11 +697,11 @@ function search_tables() {
*/
function dump_csv($row) {
foreach ($row as $key => $val) {
if (preg_match("~[\"\n,;]~", $val) || $val === "") {
if (preg_match("~[\"\n,;\t]~", $val) || $val === "") {
$row[$key] = '"' . str_replace('"', '""', $val) . '"';
}
}
echo implode(($_POST["format"] == "csv" ? "," : ";"), $row) . "\n";
echo implode(($_POST["format"] == "csv" ? "," : ($_POST["format"] == "tsv" ? "\t" : ";")), $row) . "\n";
}
/** Apply SQL function