yay - first working version of table structure output
authorchriskl <chriskl>
Sun, 12 Oct 2003 08:55:11 +0000 (08:55 +0000)
committerchriskl <chriskl>
Sun, 12 Oct 2003 08:55:11 +0000 (08:55 +0000)
HISTORY
dataexport.php
lang/english.php
lang/recoded/english.php
tblproperties.php

diff --git a/HISTORY b/HISTORY
index f3467efee495b607061133be9c825e0090b80b2b..948ad1949704d42dc7aaa6b96b5a69080917eb4d 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -5,6 +5,7 @@ Version 3.2-dev
 ---------------
 
 Features
+* Option to dump table structure, data or structure and data
 * Extra login security to prevent logging into servers as postgres and
   no password - a VERY common newbie error.
 * Cluster indexes and indexed constraints (with analyze)
index c75626c543ad0e92950eb30065600c3f5e873fb4..59cb2848f17dc3edc4ba26f3beaad2922d19a559 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Does an export to the screen or as a download
         *
-        * $Id: dataexport.php,v 1.3 2003/10/12 05:46:32 chriskl Exp $
+        * $Id: dataexport.php,v 1.4 2003/10/12 08:55:11 chriskl Exp $
         */
 
        $extensions = array(
                        // Set up the dump transaction
                        $status = $localData->beginDump();
 
-                        // If the dump is not dataonly then dump the structure prefix
-                        if (isset($_REQUEST['what']) && $_REQUEST['what'] != 'dataonly') {
+                       // If the dump is not dataonly then dump the structure prefix
+                       if (isset($_REQUEST['what']) && $_REQUEST['what'] != 'dataonly') {
                                echo $localData->getTableDefPrefix($_REQUEST['table'], isset($_REQUEST['clean']));
-                        }
+                       }
 
                        // If the dump is not structureonly then dump the actual data
                        if (isset($_REQUEST['what']) && $_REQUEST['what'] != 'structureonly') {
@@ -61,7 +61,8 @@
                                else
                                        $rs = $localData->conn->Execute($_REQUEST['query']);
 
-                               if ($_REQUEST['format'] == 'copy') {
+                               if (($_REQUEST['format'] == 'copy' && $_REQUEST['what'] == 'dataonly') || 
+                                               ($_REQUEST['what'] != 'dataonly' && $_REQUEST['format2'] == 'copy')) {
                                        $data->fieldClean($_REQUEST['table']);
                                        echo "COPY \"{$_REQUEST['table']}\"";
                                        if (isset($_REQUEST['oids'])) echo " WITH OIDS";
                                        echo "\t</records>\n";
                                        echo "</data>\n";
                                }
-                               elseif ($_REQUEST['format'] == 'sql') {
+                               elseif (($_REQUEST['format'] == 'sql' && $_REQUEST['what'] == 'dataonly') || 
+                                               ($_REQUEST['what'] != 'dataonly' && $_REQUEST['format2'] == 'sql')) {
                                        $data->fieldClean($_REQUEST['table']);
                                        while (!$rs->EOF) {
                                                echo "INSERT INTO \"{$_REQUEST['table']}\" (";
                echo "</table>\n";
 
                echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
+               echo "<input type=\"hidden\" name=\"what\" value=\"dataonly\" />\n";
                if (isset($_REQUEST['table'])) {
                        echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
                }
index 8a805efe3f20f2a4817c63e2400ea5f3ccad486d..7c14f185832aeff5a69e01d57bcab732f87e9f6d 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.112 2003/10/10 09:29:50 chriskl Exp $
+        * $Id: english.php,v 1.113 2003/10/12 08:55:11 chriskl Exp $
         */
 
        // Language and character set
        $lang['strrefresh'] = 'Refresh';
        $lang['strdownload'] = 'Download';
        $lang['strinfo'] = 'Info';
+       $lang['stroids'] = 'OIDs';
 
        // Error handling
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
        $lang['strcascade'] = 'CASCADE';
        $lang['strtablealtered'] = 'Table altered.';
        $lang['strtablealteredbad'] = 'Table alteration failed.';
+       $lang['strdataonly'] = 'Data only';
+       $lang['strstructureonly'] = 'Structure only';
+       $lang['strstructureanddata'] = 'Structure and data';
 
        // Users
        $lang['struser'] = 'User';
index 60820df7d5a0928c4d6ab4481555bd9689a9eee4..1276ddb7bb78c4f974c881cb42bc1bf5a1ef9a10 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.64 2003/10/10 09:29:50 chriskl Exp $
+        * $Id: english.php,v 1.65 2003/10/12 08:55:11 chriskl Exp $
         */
 
        // Language and character set
        $lang['strrefresh'] = 'Refresh';
        $lang['strdownload'] = 'Download';
        $lang['strinfo'] = 'Info';
+       $lang['stroids'] = 'OIDs';
 
        // Error handling
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
        $lang['strcascade'] = 'CASCADE';
        $lang['strtablealtered'] = 'Table altered.';
        $lang['strtablealteredbad'] = 'Table alteration failed.';
+       $lang['strdataonly'] = 'Data only';
+       $lang['strstructureonly'] = 'Structure only';
+       $lang['strstructureanddata'] = 'Structure and data';
 
        // Users
        $lang['struser'] = 'User';
index 498c6833cc4ba2c04175589d36e804fccd1b6b5d..12fc0627554b976db4d1843e0b1d9bc025d8376d 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tblproperties.php,v 1.26 2003/10/01 15:50:30 soranzo Exp $
+        * $Id: tblproperties.php,v 1.27 2003/10/12 08:55:11 chriskl Exp $
         */
 
        // Include application functions
                global $data, $localData, $misc;
                global $PHP_SELF, $lang;
 
+               // Determine whether or not the table has an object ID
+               $hasID = $localData->hasObjectID($_REQUEST['table']);
+               
                $misc->printTableNav();
                echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strexport']}</h2>\n";
                $misc->printMsg($msg);
 
                echo "<form action=\"dataexport.php\" method=\"post\">\n";
                echo "<table>\n";
-               echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strformat']}</th>\n";
-               echo "\t\t<td>\n\t\t\t<select name=\"format\">\n";
-               echo "\t\t\t\t<option value=\"copy\">COPY</option>\n";
-               echo "\t\t\t\t<option value=\"sql\">SQL</option>\n";
-               echo "\t\t\t\t<option value=\"csv\">CSV</option>\n";
-               echo "\t\t\t\t<option value=\"tab\">Tabbed</option>\n";
-               echo "\t\t\t\t<option value=\"html\">XHTML</option>\n";
-               echo "\t\t\t\t<option value=\"xml\">XML</option>\n";
-               echo "\t\t\t</select>\n\t\t</td>\n\t</tr>\n";
-               echo "\t<tr>\n\t\t<th class=\"data left\">OIDS?</th>\n";
-               echo "\t\t<td><input type=\"checkbox\" name=\"oids\" /></td>\n\t</tr>\n";
-               echo "\t<tr>\n\t\t<th class=\"data left\">Download?</th>\n";
-               echo "\t\t<td><input type=\"checkbox\" name=\"download\" /></td>\n\t</tr>\n";
+               echo "<tr><th class=\"data\">{$lang['strformat']}</th><th class=\"data\" colspan=\"2\">{$lang['stroptions']}</th></tr>\n";
+               // Data only
+               echo "<tr><th class=\"data left\" rowspan=\"", ($hasID) ? 2 : 1, "\">";
+               echo "<input type=\"radio\" name=\"what\" value=\"dataonly\" checked=\"checked\" />{$lang['strdataonly']}</th>\n";
+               echo "<td>{$lang['strformat']}</td>\n";
+               echo "<td><select name=\"format\">\n";
+               echo "<option value=\"copy\">COPY</option>\n";
+               echo "<option value=\"sql\">SQL</option>\n";
+               echo "<option value=\"csv\">CSV</option>\n";
+               echo "<option value=\"tab\">Tabbed</option>\n";
+               echo "<option value=\"html\">XHTML</option>\n";
+               echo "<option value=\"xml\">XML</option>\n";
+               echo "</select>\n</td>\n</tr>\n";
+               if ($hasID) {
+                       echo "<td>{$lang['stroids']}</td><td><input type=\"checkbox\" name=\"oids\" /></td>\n</tr>\n";
+               }
+               // Structure only
+               echo "<tr><th class=\"data left\"><input type=\"radio\" name=\"what\" value=\"structureonly\" />{$lang['strstructureonly']}</th>\n";
+               echo "<td>{$lang['strdrop']}</td><td><input type=\"checkbox\" name=\"clean\" /></td>\n</tr>\n";
+               // Structure and data
+               echo "<tr><th class=\"data left\" rowspan=\"", ($hasID) ? 3 : 2, "\">";
+               echo "<input type=\"radio\" name=\"what\" value=\"structureanddata\" />{$lang['strstructureanddata']}</th>\n";
+               echo "<td>{$lang['strformat']}</td>\n";
+               echo "<td><select name=\"format2\">\n";
+               echo "<option value=\"copy\">COPY</option>\n";
+               echo "<option value=\"sql\">SQL</option>\n";
+               echo "</select>\n</td>\n</tr>\n";
+               echo "<td>{$lang['strdrop']}</td><td><input type=\"checkbox\" name=\"clean\" /></td>\n</tr>\n";
+               if ($hasID) {
+                       echo "<td>{$lang['stroids']}</td><td><input type=\"checkbox\" name=\"oids\" /></td>\n</tr>\n";
+               }
+               echo "</table>\n";
+               
+               echo "<h3>{$lang['stroptions']}</h3>\n";
+               echo "<table>\n";               
+               echo "<tr>\n<th class=\"data left\">{$lang['strdownload']}</th>\n";
+               echo "<td><input type=\"checkbox\" name=\"download\" /></td>\n</tr>\n";
                echo "</table>\n";
 
                echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
                                
                                $status = $localData->alterColumn($_REQUEST['table'], $_REQUEST['column'], $_REQUEST['field'], 
                                                                isset($_REQUEST['notnull']), $_REQUEST['default'], $_REQUEST['olddefault']);
+echo "status: $status";                
                                if ($status == 0)
                                        doDefault($lang['strcolumnaltered']);
                                else {