From: chriskl Date: Sun, 3 Aug 2003 03:14:13 +0000 (+0000) Subject: Lots of NULL value in table dump fixes (XML format changed slightly) X-Git-Tag: REL_3-0-1~29 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=3c5879c032ad280b26ec98790ee48fb9ef574fea;p=phppgadmin.git Lots of NULL value in table dump fixes (XML format changed slightly) --- diff --git a/HISTORY b/HISTORY index cdbb5319..2489c4bf 100644 --- a/HISTORY +++ b/HISTORY @@ -15,6 +15,7 @@ Version 3.1 * Add/drop users to/from groups * Alter (rename) triggers * Pop-up SQL window from Mark Gibson +* Lots of NULL value in table dump fixes (XML format changed slightly) Version 3.0 ----------- diff --git a/tblexport.php b/tblexport.php index 22b5cc65..02b4fbc4 100644 --- a/tblexport.php +++ b/tblexport.php @@ -3,7 +3,7 @@ /** * Does an export to the screen or as a download * - * $Id: tblexport.php,v 1.7 2003/06/30 02:14:03 chriskl Exp $ + * $Id: tblexport.php,v 1.8 2003/08/03 03:14:13 chriskl Exp $ */ $extensions = array( @@ -72,7 +72,7 @@ $k = htmlspecialchars($k); $v = htmlspecialchars($v); - echo "\t\t<{$k}>{$v}\n"; + echo "\t\t<{$k}", ($v == null ? ' null="true"' : ''), ">{$v}\n"; } echo "\t\n"; $rs->moveNext(); @@ -92,14 +92,16 @@ if ($first) echo "\"{$k}\""; else echo ", \"{$k}\""; - // Output value - // addCSlashes converts all weird ASCII characters to octal representation, - // EXCEPT the 'special' ones like \r \n \t, etc. - $v = addCSlashes($v, "\0..\37\177..\377"); - // We add an extra escaping slash onto octal encoded characters - $v = ereg_replace('\\\\([0-7]{3})', '\\\1', $v); - // Finally, escape all apostrophes - $v = str_replace("'", "''", $v); + if ($v != null) { + // Output value + // addCSlashes converts all weird ASCII characters to octal representation, + // EXCEPT the 'special' ones like \r \n \t, etc. + $v = addCSlashes($v, "\0..\37\177..\377"); + // We add an extra escaping slash onto octal encoded characters + $v = ereg_replace('\\\\([0-7]{3})', '\\\1', $v); + // Finally, escape all apostrophes + $v = str_replace("'", "''", $v); + } if ($first) { $values = ($v === null) ? 'NULL' : "'{$v}'"; $first = false; @@ -117,20 +119,20 @@ if ($k == $localData->id && !isset($_REQUEST['oids'])) continue; switch ($_REQUEST['format']) { case 'csv': - $v = str_replace('"', '""', $v); + if ($v != null) $v = str_replace('"', '""', $v); if ($first) { - echo "\"{$v}\""; + echo ($v == null) ? "\"\\N\"" : "\"{$v}\""; $first = false; } - else echo ",\"{$v}\""; + else echo ($v == null) ? ",\"\\N\"" : ",\"{$v}\""; break; case 'tab': - $v = str_replace('"', '""', $v); + if ($v != null) $v = str_replace('"', '""', $v); if ($first) { - echo "\"{$v}\""; + echo ($v == null) ? "\"\\N\"" : "\"{$v}\""; $first = false; } - else echo "\t\"{$v}\""; + else echo ($v == null) ? "\t\"\\N\"" : "\t\"{$v}\""; break; } }