[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_3_7-10513-ge91e878

Marc Delisle lem9 at users.sourceforge.net
Sun Oct 3 13:46:50 CEST 2010


The branch, master has been updated
       via  e91e87861b7e7dff68780fcfc056ac0f0c35885d (commit)
       via  0df2fcd70d5d8f3c2671d38f9fad668f6937251a (commit)
       via  f503d5667e481b65b6249966e3d5da97b013ea3f (commit)
       via  22fa5adee3cece9229f457d724d516eb96975186 (commit)
      from  864fb1a0038d1c3c3a7c2e649176e0e86fbdd622 (commit)


- Log -----------------------------------------------------------------
commit e91e87861b7e7dff68780fcfc056ac0f0c35885d
Author: Marc Delisle <marc at infomarc.info>
Date:   Sun Oct 3 07:45:15 2010 -0400

    make USE work in the context of ajaxification

commit 0df2fcd70d5d8f3c2671d38f9fad668f6937251a
Merge: f503d5667e481b65b6249966e3d5da97b013ea3f 864fb1a0038d1c3c3a7c2e649176e0e86fbdd622
Author: Marc Delisle <marc at infomarc.info>
Date:   Sat Oct 2 16:34:55 2010 -0400

    Merge branch 'master' of ssh://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin

commit f503d5667e481b65b6249966e3d5da97b013ea3f
Merge: 15eda6f4414fc3d2ff0d16346db28a698f52bc00 22fa5adee3cece9229f457d724d516eb96975186
Author: Marc Delisle <marc at infomarc.info>
Date:   Wed Sep 29 08:04:47 2010 -0400

    Merge branch 'QA_3_3'

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                |    1 +
 js/sql.js                |   37 ++++++++++++++++++++++++++-----------
 libraries/import.lib.php |   27 +++++++++++++++++++++++----
 sql.php                  |    5 ++++-
 4 files changed, 54 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d187e2a..8d5e79a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -123,6 +123,7 @@
 - [core] Update library PHPExcel to version 1.7.4
 - bug #3062455 [core] copy procedures and routines before tables
 - bug #3062455 [export] with SQL, export procedures and routines before tables
+- bug #3056023 [import] USE query not working
 
 3.3.7.0 (2010-09-07)
 - patch #3050492 [PDF scratchboard] Cannot drag table box to the edge after
diff --git a/js/sql.js b/js/sql.js
index 126784d..285df0f 100644
--- a/js/sql.js
+++ b/js/sql.js
@@ -155,14 +155,17 @@ $(document).ready(function() {
      * @memberOf jQuery
      * @name    appendToggleSpan
      */
-    $('<span id="togglequerybox"></span>')
-    .html(PMA_messages['strToggleQueryBox'])
-    .appendTo("#sqlqueryform");
-
-    // Attach the toggling of the query box visibility to a click
-    $("#togglequerybox").live('click', function() {
-        $(this).siblings().slideToggle("medium");
-    })
+    // do not add this span more than once
+    if (! $('#sqlqueryform').find('span').is('#togglequerybox')) {
+        $('<span id="togglequerybox"></span>')
+        .html(PMA_messages['strToggleQueryBox'])
+        .appendTo("#sqlqueryform");
+
+        // Attach the toggling of the query box visibility to a click
+        $("#togglequerybox").bind('click', function() {
+            $(this).siblings().slideToggle("medium");
+        })
+    }
     
     /**
      * Ajax Event handler for 'SQL Query Submit'
@@ -173,17 +176,29 @@ $(document).ready(function() {
      */
     $("#sqlqueryform").live('submit', function(event) {
         event.preventDefault();
-
+        $form = $(this);
         PMA_ajaxShowMessage();
 
-        $(this).append('<input type="hidden" name="ajax_request" value="true" />');
+	    if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
+        	$form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
+	    }
 
         $.post($(this).attr('action'), $(this).serialize() , function(data) {
             if(data.success == true) {
                 PMA_ajaxShowMessage(data.message);
+                // this happens if a USE command was typed
+                if (typeof data.reload != 'undefined') {
+                    $form.find('input[name=db]').val(data.db);
+                    // need to regenerate the whole upper part
+                    $form.find('input[name=ajax_request]').remove();
+                    $form.append('<input type="hidden" name="reload" value="true" />');
+                    $.post('db_sql.php', $form.serialize(), function(data) {
+                        $('body').html(data);
+                    }); // end inner post
+                }
             }
             else if (data.success == false ) {
-                PMA_ajaxShowMessage(data.error);
+                PMA_ajaxShowMessage(data.error, 50000);
             }
             else {
                 $("#sqlqueryresults").html(data);
diff --git a/libraries/import.lib.php b/libraries/import.lib.php
index 98221de..79a43b7 100644
--- a/libraries/import.lib.php
+++ b/libraries/import.lib.php
@@ -117,6 +117,8 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
                             $display_query = '';
                         }
                         $sql_query = $import_run_buffer['sql'];
+                        // If a 'USE <db>' SQL-clause was found, set our current $db to the new one
+                        list($db, $reload) = PMA_lookForUse($import_run_buffer['sql'], $db, $reload);
                     } elseif ($run_query) {
                         if ($controluser) {
                             $result = PMA_query_as_controluser($import_run_buffer['sql']);
@@ -156,10 +158,8 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
                         }
                         
                         // If a 'USE <db>' SQL-clause was found and the query succeeded, set our current $db to the new one
-                        if ($result != FALSE && preg_match('@^[\s]*USE[[:space:]]*([\S]+)@i', $import_run_buffer['sql'], $match)) {
-                            $db = trim($match[1]);
-                            $db = trim($db,';'); // for example, USE abc;
-                            $reload = TRUE;
+                        if ($result != FALSE) {
+                            list($db, $reload) = PMA_lookForUse($import_run_buffer['sql'], $db, $reload);
                         }
                         
                         if ($result != FALSE && preg_match('@^[\s]*(DROP|CREATE)[\s]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)@im', $import_run_buffer['sql'])) {
@@ -205,6 +205,25 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
     }
 }
 
+/**
+ * Looks for the presence of USE to possibly change current db  
+ *
+ * @param  string buffer to examine 
+ * @param  string current db 
+ * @param  boolean reload 
+ * @return array (current or new db, whether to reload) 
+ * @access public
+ */
+function PMA_lookForUse($buffer, $db, $reload)
+{ 
+    if (preg_match('@^[\s]*USE[[:space:]]*([\S]+)@i', $buffer, $match)) {
+        $db = trim($match[1]);
+        $db = trim($db,';'); // for example, USE abc;
+        $reload = TRUE;
+    }
+    return(array($db, $reload));
+}
+
 
 /**
  * Returns next part of imported file/buffer
diff --git a/sql.php b/sql.php
index 698ca8a..898c893 100644
--- a/sql.php
+++ b/sql.php
@@ -677,7 +677,10 @@ if (0 == $num_rows || $is_affected) {
         if(isset($GLOBALS['display_query'])) {
             $extra_data['sql_query'] = PMA_showMessage(NULL, $GLOBALS['display_query']);
         }
-
+        if ($GLOBALS['reload'] == 1) {
+            $extra_data['reload'] = 1;
+            $extra_data['db'] = $GLOBALS['db'];
+        } 
         PMA_ajaxResponse($message, $message->isSuccess(), (isset($extra_data) ? $extra_data : ''));
     }
 


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list