Lots of NULL value in table dump fixes (XML format changed slightly)
authorchriskl <chriskl>
Sun, 3 Aug 2003 03:14:13 +0000 (03:14 +0000)
committerchriskl <chriskl>
Sun, 3 Aug 2003 03:14:13 +0000 (03:14 +0000)
HISTORY
tblexport.php

diff --git a/HISTORY b/HISTORY
index cdbb53198020e407519c2471f48f1af3616b1e3a..2489c4bf069ab19aa2791374c9d3a2805100f9ad 100644 (file)
--- 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
 -----------
index 22b5cc65dc7aaf7f7fce9936ae713498d437ac5a..02b4fbc4b324c8fddefabee1677c797c4c1c4fe3 100644 (file)
@@ -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}</{$k}>\n";
+                               echo "\t\t<{$k}", ($v == null ? ' null="true"' : ''), ">{$v}</{$k}>\n";
                        }
                        echo "\t</row>\n";
                        $rs->moveNext();
                                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;
                                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;
                                }
                        }