Skip to content

Commit

Permalink
Refactor the sql functions into static methods
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information
MauricioFauth committed May 31, 2017
1 parent 572c4b7 commit 2124311
Show file tree
Hide file tree
Showing 17 changed files with 2,605 additions and 2,626 deletions.
7 changes: 4 additions & 3 deletions db_qbe.php
Expand Up @@ -5,15 +5,16 @@
*
* @package PhpMyAdmin
*/

use PMA\libraries\Response;
use PMA\libraries\SavedSearches;
use PMA\libraries\Sql;
use PMA\libraries\URL;
use PMA\libraries\Response;

/**
* requirements
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/sql.lib.php';

$response = Response::getInstance();

Expand Down Expand Up @@ -81,7 +82,7 @@
$message_to_display = true;
} else {
$goto = 'db_sql.php';
PMA_executeQueryAndSendQueryResponse(
Sql::executeQueryAndSendQueryResponse(
null, // analyzed_sql_results
false, // is_gotofile
$_REQUEST['db'], // db
Expand Down
20 changes: 10 additions & 10 deletions import.php
Expand Up @@ -5,12 +5,14 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\Response;

use PMA\libraries\Bookmark;
use PMA\libraries\Encoding;
use PMA\libraries\plugins\ImportPlugin;
use PMA\libraries\File;
use PMA\libraries\plugins\ImportPlugin;
use PMA\libraries\Response;
use PMA\libraries\Sql;
use PMA\libraries\URL;
use PMA\libraries\Bookmark;

/* Enable LOAD DATA LOCAL INFILE for LDI plugin */
if (isset($_POST['format']) && $_POST['format'] == 'ldi') {
Expand All @@ -21,8 +23,6 @@
* Get the variables sent or posted to this script and a core script
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/sql.lib.php';
//require_once 'libraries/display_import_functions.lib.php';

if (isset($_REQUEST['show_as_php'])) {
$GLOBALS['show_as_php'] = $_REQUEST['show_as_php'];
Expand Down Expand Up @@ -695,7 +695,7 @@
extract($analyzed_sql_results);

// Check if User is allowed to issue a 'DROP DATABASE' Statement
if (PMA_hasNoRightsToDropDatabase(
if (Sql::hasNoRightsToDropDatabase(
$analyzed_sql_results, $cfg['AllowUserDropDatabase'], $GLOBALS['is_superuser']
)) {
PMA\libraries\Util::mysqlDie(
Expand All @@ -711,7 +711,7 @@
$table = $table_from_sql;
}

$html_output .= PMA_executeQueryAndGetQueryResponse(
$html_output .= Sql::executeQueryAndGetQueryResponse(
$analyzed_sql_results, // analyzed_sql_results
false, // is_gotofile
$db, // db
Expand All @@ -733,12 +733,12 @@
);
}

// sql_query_for_bookmark is not included in PMA_executeQueryAndGetQueryResponse
// sql_query_for_bookmark is not included in Sql::executeQueryAndGetQueryResponse
// since only one bookmark has to be added for all the queries submitted through
// the SQL tab
if (! empty($_POST['bkm_label']) && ! empty($import_text)) {
$cfgBookmark = Bookmark::getParams();
PMA_storeTheQueryAsBookmark(
Sql::storeTheQueryAsBookmark(
$db, $cfgBookmark['user'],
$_REQUEST['sql_query'], $_POST['bkm_label'],
isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null
Expand All @@ -753,7 +753,7 @@
// Save a Bookmark with more than one queries (if Bookmark label given).
if (! empty($_POST['bkm_label']) && ! empty($import_text)) {
$cfgBookmark = Bookmark::getParams();
PMA_storeTheQueryAsBookmark(
Sql::storeTheQueryAsBookmark(
$db, $cfgBookmark['user'],
$_REQUEST['sql_query'], $_POST['bkm_label'],
isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null
Expand Down
12 changes: 4 additions & 8 deletions libraries/DisplayResults.php
Expand Up @@ -9,8 +9,9 @@

use PhpMyAdmin\SqlParser\Utils\Query;
use PMA\libraries\plugins\transformations\Text_Plain_Link;
use PMA\libraries\URL;
use PMA\libraries\Sanitize;
use PMA\libraries\Sql;
use PMA\libraries\URL;

require_once './libraries/transformations.lib.php';

Expand Down Expand Up @@ -1429,7 +1430,7 @@ private function _getSortByKeyDropDown(
. URL::getHiddenInputs(
$this->__get('db'), $this->__get('table')
)
// to avoid calling PMA_handleSortOrder() later
// to avoid calling Sql::handleSortOrder() later
. URL::getHiddenFields(array('sort_by_key' => '1'))
. __('Sort by key')
. ': <select name="sql_query" class="autosubmit">' . "\n";
Expand Down Expand Up @@ -4256,19 +4257,14 @@ public function getTable(
$showtable = $this->__get('showtable');
$printview = $this->__get('printview');

// why was this called here? (already called from sql.php)
//$this->setConfigParamsForDisplayTable();

/**
* @todo move this to a central place
* @todo for other future table types
*/
$is_innodb = (isset($showtable['Type'])
&& $showtable['Type'] == self::TABLE_TYPE_INNO_DB);

if ($is_innodb
&& PMA_isJustBrowsing($analyzed_sql_results, true)
) {
if ($is_innodb && Sql::isJustBrowsing($analyzed_sql_results, true)) {
// "j u s t b r o w s i n g"
$pre_count = '~';
$after_count = Util::showHint(
Expand Down

0 comments on commit 2124311

Please sign in to comment.