From eeea3d6845016d0b20cf5ebc4b0c5139bcd28e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 13 Jan 2011 13:42:24 +0100 Subject: [PATCH] [export] Better handling of export to PHP array. There is no need for own logic here, we can use var_export. --- ChangeLog | 1 + libraries/export/php_array.php | 19 ++++--------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 889c140ed..60985a147 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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, diff --git a/libraries/export/php_array.php b/libraries/export/php_array.php index 5cf6fb760..983673c68 100644 --- a/libraries/export/php_array.php +++ b/libraries/export/php_array.php @@ -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;