allow paging of SQL box queries. allow EXPLAIN ANALYZE of sql queries. default...
authorchriskl <chriskl>
Fri, 13 Feb 2004 08:53:04 +0000 (08:53 +0000)
committerchriskl <chriskl>
Fri, 13 Feb 2004 08:53:04 +0000 (08:53 +0000)
HISTORY
classes/Misc.php
database.php
lang/english.php
lang/recoded/english.php
sql.php
sqledit.php

diff --git a/HISTORY b/HISTORY
index a2a0948d5a43cc0e54255512457b594cdac118fa..073eaba823fce7822547be7304aaa2b1323f394e 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -16,6 +16,9 @@ Features
 * Rename user feature for PostgreSQL >= 7.4
 * Create functions returning arrays and table types
 * Allow editing Select results by oid
+* Allow pagination of queries entered in the SQL box
+* Allow EXPLAIN ANALYZE of SQL queries
+* Default cursor conveniently in SQL box and Find
 
 Bugs
 * Object browser fixed for databases with no schemas
index e08dd8403837ea8c1b29003324ea7b7ab6da31c2..fc999ba78b55b6cafc2c772fc57fa79dad9574cf 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.58 2004/02/02 12:15:57 chriskl Exp $
+        * $Id: Misc.php,v 1.59 2004/02/13 08:53:05 chriskl Exp $
         */
         
        class Misc {
                 * Displays link to the context help.if $conf['docsdir'] is set
                 * @param $url - last part of a document's url (relative to $conf['docsdir'])
                 */
-
                function printHelp($url) {
                        global $lang, $conf;
 
                        }
                }
        
+               /** 
+                * Outputs JavaScript to set default focus
+                * @param $object eg. forms[0].username
+                */
+               function setFocus($object) {
+                       echo "<script language=\"JavaScript\">\n";
+                       echo "<!--\n";
+                       echo "   document.{$object}.focus();\n";
+                       echo "-->\n";
+                       echo "</script>\n";             
+               }
+                
        }
 ?>
index c6d0c5c349d5db26c77054427d11761e6509eeb5..53028039ace9062ba3a27b430bbe070a7774bea4 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.34 2004/02/02 12:15:57 chriskl Exp $
+        * $Id: database.php,v 1.35 2004/02/13 08:53:04 chriskl Exp $
         */
 
        // Include application functions
@@ -38,6 +38,9 @@
                echo "<input type=\"hidden\" name=\"action\" value=\"find\" />\n";
                echo "</form>\n";
                
+               // Default focus
+               $misc->setFocus('forms[0].term');
+
                // If a search term has been specified, then perform the search
                // and display the results, grouped by object type
                if ($_GET['term'] != '') {
                        htmlspecialchars($_REQUEST['query']), "</textarea></p>\n";
 
                echo $misc->form;
+               echo "<input type=\"checkbox\" name=\"paginate\"", (isset($_REQUEST['paginate']) ? ' checked="checked"' : ''), " /> {$lang['strpaginate']}\n";
+               echo "<br /><br />\n";
                echo "<input type=\"submit\" value=\"{$lang['strgo']}\" />\n";
                echo "</form>\n";
+
+               // Default focus
+               $misc->setFocus('forms[0].query');
        }
 
        /**
index bb9352b049f4b5860753dfd6d6f4f56cf81ccdf4..a89ca78d2aa9d4af6848930800d56bf934e84cc9 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.131 2004/02/02 12:15:58 chriskl Exp $
+        * $Id: english.php,v 1.132 2004/02/13 08:53:05 chriskl Exp $
         */
 
        // Language and character set
        $lang['strexpand'] = 'Expand';
        $lang['strcollapse'] = 'Collapse';
        $lang['strexplain'] = 'Explain';
+       $lang['strexplainanalyze'] = 'Explain Analyze';
        $lang['strfind'] = 'Find';
        $lang['stroptions'] = 'Options';
        $lang['strrefresh'] = 'Refresh';
        $lang['strprocesses'] = 'Processes';
        $lang['strsetting'] = 'Setting';
        $lang['strparameters'] = 'Parameters';
-       $lang['streditquery'] = 'Edit query';
+       $lang['streditsql'] = 'Edit SQL';
+       $lang['strpaginate'] = 'Paginate results';
        $lang['strstarttime'] = 'Start Time';
 
        // Error handling
index 1309ca3904ad983da9d1e06a4cc65e603970d4aa..ea296235310480a0c30b6488b4524384ec1e83da 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.83 2004/02/02 12:15:58 chriskl Exp $
+        * $Id: english.php,v 1.84 2004/02/13 08:53:05 chriskl Exp $
         */
 
        // Language and character set
        $lang['strexpand'] = 'Expand';
        $lang['strcollapse'] = 'Collapse';
        $lang['strexplain'] = 'Explain';
+       $lang['strexplainanalyze'] = 'Explain Analyze';
        $lang['strfind'] = 'Find';
        $lang['stroptions'] = 'Options';
        $lang['strrefresh'] = 'Refresh';
        $lang['strprocesses'] = 'Processes';
        $lang['strsetting'] = 'Setting';
        $lang['strparameters'] = 'Parameters';
-       $lang['streditquery'] = 'Edit query';
+       $lang['streditsql'] = 'Edit SQL';
+       $lang['strpaginate'] = 'Paginate results';
        $lang['strstarttime'] = 'Start Time';
 
        // Error handling
diff --git a/sql.php b/sql.php
index 4b50e3fe35c4c503b0376f23e4c8412e15ca23c0..fc455cfd506b17b70671fbbb6f16d98a65f3b107 100644 (file)
--- a/sql.php
+++ b/sql.php
@@ -6,11 +6,20 @@
         * how many SQL statements have been strung together with semi-colons
         * @param $query The SQL query string to execute
         *
-        * $Id: sql.php,v 1.14 2003/12/17 09:11:32 chriskl Exp $
+        * $Id: sql.php,v 1.15 2004/02/13 08:53:04 chriskl Exp $
         */
 
        // Include application functions
        include_once('./libraries/lib.inc.php');
+
+       // Check to see if pagination has been specified.  In that case, send to display
+       // script for pagination
+       if (isset($_POST['paginate'])) {
+               $_REQUEST['return_url'] = "database.php?{$misc->href}&action=sql&paginate=on&query=" . urlencode($_POST['query']);
+               $_REQUEST['return_desc'] = $lang['streditsql'];
+               include('./display.php');
+               exit;
+       }
        
        $PHP_SELF = $_SERVER['PHP_SELF'];
 
        echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strsql']}: {$lang['strqueryresults']}</h2>\n";
 
        // NOTE: This is a quick hack!
+       // TODO: Is there a generic (non PostgreSQL specific) way to do this
        if (isset($_POST['explain']) && isset($_POST['query'])) {
-               // TODO: Is there a generic (non PostgreSQL specific) way to do this
                $_POST['query'] = 'EXPLAIN ' . $_POST['query'];
        }
+       elseif (isset($_POST['explain_analyze']) && isset($_POST['query'])) {
+               $_POST['query'] = 'EXPLAIN ANALYZE ' . $_POST['query'];
+       }
        
        // Set fetch mode to NUM so that duplicate field names are properly returned
        $data->conn->setFetchMode(ADODB_FETCH_NUM);
@@ -66,7 +78,7 @@
        }
 
        echo "<p><a class=\"navlink\" href=\"database.php?database=", urlencode($_REQUEST['database']),
-               "&amp;action=sql&amp;query=", urlencode($_POST['query']), "\">{$lang['strback']}</a>";
+               "&amp;action=sql&amp;query=", urlencode($_POST['query']), "\">{$lang['streditsql']}</a>";
        if ($conf['show_reports'] && isset($rs) && is_object($rs) && $rs->recordCount() > 0) {
                echo " | <a class=\"navlink\" href=\"reports.php?action=create&amp;db_name=", urlencode($_REQUEST['database']), "&amp;report_sql=",
                        urlencode($_POST['query']), "\">{$lang['strcreatereport']}</a>";
index df55b3ce603dafb4bb13d366c0fa7b52b5143bf4..c1324f91a53bc6ba3eb7c043cd0e9eb9973b8f9d 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Alternative SQL editing window
         *
-        * $Id: sqledit.php,v 1.10 2003/12/17 09:11:32 chriskl Exp $
+        * $Id: sqledit.php,v 1.11 2004/02/13 08:53:04 chriskl Exp $
         */
 
        // Include application functions
@@ -59,6 +59,9 @@
                echo $misc->form;
                echo "<input type=\"hidden\" name=\"action\" value=\"find\" />\n";
                echo "</form>\n";
+
+               // Default focus
+               $misc->setFocus('forms[0].term');
        }
 
        /**
 
                echo "<textarea style=\"width: 100%\" rows=\"10\" cols=\"50\" name=\"query\">",
                        htmlspecialchars($_POST['query']), "</textarea>\n";
+               echo "<input type=\"checkbox\" name=\"paginate\"", (isset($_REQUEST['paginate']) ? ' checked="checked"' : ''), " /> {$lang['strpaginate']}\n";
+               echo "<br />\n";
                echo "<p><input type=\"submit\" value=\"{$lang['strgo']}\" />\n";
                echo "<input type=\"submit\" name=\"explain\" value=\"{$lang['strexplain']}\" />\n";
+               echo "<input type=\"submit\" name=\"explain_analyze\" value=\"{$lang['strexplainanalyze']}\" />\n";
                echo "<input type=\"reset\" value=\"{$lang['strreset']}\" /></p>\n";
 
                echo $misc->form;
 
                echo "</form>\n";
+               
+               // Default focus
+               $misc->setFocus('forms[0].query');
        }
 
        $misc->printHeader($lang['strsql']);