[export] Better handling of export to PHP array.

There is no need for own logic here, we can use var_export.
This commit is contained in:
Michal Čihař
2011-01-13 13:42:24 +01:00
parent 89833a0603
commit eeea3d6845
2 changed files with 5 additions and 15 deletions

View File

@@ -128,6 +128,7 @@
+ rfe #3141330 [relation] When displaying results, show a link to the foreign
table even when phpMyAdmin configuration storage is not active
- bug #3141327 [relation] Foreign key input options
- [export] Better handling of export to PHP array.
3.3.10.0 (not yet released)
- patch #3147400 [structure] Aria table size printed as unknown,

View File

@@ -147,7 +147,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
while ($record = PMA_DBI_fetch_row($result)) {
$record_cnt++;
// Output table name as comment if this is the first record of the table
if ($record_cnt == 1) {
$buffer .= $crlf . '// ' . $db . '.' . $table . $crlf;
@@ -159,28 +159,17 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
for ($i = 0; $i < $columns_cnt; $i++) {
$isLastLine = ($i + 1 >= $columns_cnt);
$column = $columns[$i];
if (is_null($record[$i])) {
$buffer .= "'" . $column . "'=>null" . (! $isLastLine ? ',' : '');
} elseif (is_numeric($record[$i])) {
$buffer .= "'" . $column . "'=>" . $record[$i] . (! $isLastLine ? ',' : '');
} else {
$buffer .= "'" . $column . "'=>'" . addslashes($record[$i]) . "'" . (! $isLastLine ? ',' : '');
}
$buffer .= "'" . $columns[$i]. "'=>" . var_export($record[$i], true) . (($i + 1 >= $columns_cnt) ? '' : ',');
}
$buffer .= ')';
}
$buffer .= $crlf . ');' . $crlf;
if (! PMA_exportOutputHandler($buffer)) {
return FALSE;
}
PMA_DBI_free_result($result);
return true;