Merge branch 'master' of https://github.com/phpmyadmin/phpmyadmin into UT_plu_parse
This commit is contained in:
commit
ada2716826
@ -1103,18 +1103,6 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
$GLOBALS['is_ajax_request'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @global boolean $GLOBALS['grid_edit']
|
||||
*
|
||||
* Set to true if this is a request made during an grid edit process. This
|
||||
* request is made to retrieve the non-truncated/transformed values.
|
||||
*/
|
||||
if (isset($_REQUEST['grid_edit']) && $_REQUEST['grid_edit'] == true) {
|
||||
$GLOBALS['grid_edit'] = true;
|
||||
} else {
|
||||
$GLOBALS['grid_edit'] = false;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) {
|
||||
PMA_fatalError(__("GLOBALS overwrite attempt"));
|
||||
}
|
||||
|
||||
@ -74,6 +74,18 @@ $is_count = isset($analyzed_sql[0]['queryflags']['is_count']);
|
||||
// check for a real SELECT ... FROM
|
||||
$is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
|
||||
|
||||
// check for CALL
|
||||
// Since multiple query execution is anyway handled,
|
||||
// ignore the WHERE clause of the first sql statement
|
||||
// which might contain a phrase like 'call '
|
||||
if (isset($analyzed_sql[0]['queryflags']['is_procedure'])
|
||||
&& empty($analyzed_sql[0]['where_clause'])
|
||||
) {
|
||||
$is_procedure = true;
|
||||
} else {
|
||||
$is_procedure = false;
|
||||
}
|
||||
|
||||
// aggregates all the results into one array
|
||||
$analyzed_sql_results = array(
|
||||
"parsed_sql" => $parsed_sql,
|
||||
@ -92,7 +104,8 @@ $analyzed_sql_results = array(
|
||||
"is_group" => $is_group,
|
||||
"is_func" => $is_func,
|
||||
"is_count" => $is_count,
|
||||
"is_select" => $is_select
|
||||
"is_select" => $is_select,
|
||||
"is_procedure" => $is_procedure
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ function PMA_getTableNameBySQL($sql, $tables)
|
||||
*
|
||||
* @return string $table_html html content
|
||||
*/
|
||||
function getTableHtmlForMultipleQueries(
|
||||
function PMA_getTableHtmlForMultipleQueries(
|
||||
$displayResultsObject, $db, $sql_data, $goto, $pmaThemeImage,
|
||||
$text_dir, $printview, $url_query, $disp_mode, $sql_limit_to_append,
|
||||
$editable
|
||||
@ -381,7 +381,8 @@ function PMA_getHtmlForRelationalColumnDropdown($db, $table, $column, $curr_valu
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTML for the header of the page in print view
|
||||
* Get the HTML for the header of the page in print view if print view is selected.
|
||||
* Otherwise returns null.
|
||||
*
|
||||
* @param string $db current database
|
||||
* @param string $sql_query current sql query
|
||||
@ -391,80 +392,160 @@ function PMA_getHtmlForRelationalColumnDropdown($db, $table, $column, $curr_valu
|
||||
*/
|
||||
function PMA_getHtmlForPrintViewHeader($db, $sql_query, $num_rows)
|
||||
{
|
||||
$hostname = '';
|
||||
if ( $GLOBALS['cfg']['Server']['verbose']) {
|
||||
$hostname = $GLOBALS['cfg']['Server']['verbose'];
|
||||
} else {
|
||||
$hostname = $GLOBALS['cfg']['Server']['host'];
|
||||
if (! empty( $GLOBALS['cfg']['Server']['port'])) {
|
||||
$hostname .= $GLOBALS['cfg']['Server']['port'];
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
if (isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
|
||||
PMA_Util::checkParameters(array('db', 'full_sql_query'));
|
||||
$header->enablePrintView();
|
||||
$hostname = '';
|
||||
if ( $GLOBALS['cfg']['Server']['verbose']) {
|
||||
$hostname = $GLOBALS['cfg']['Server']['verbose'];
|
||||
} else {
|
||||
$hostname = $GLOBALS['cfg']['Server']['host'];
|
||||
if (! empty( $GLOBALS['cfg']['Server']['port'])) {
|
||||
$hostname .= $GLOBALS['cfg']['Server']['port'];
|
||||
}
|
||||
}
|
||||
|
||||
$versions = "phpMyAdmin " . PMA_VERSION;
|
||||
$versions .= " / ";
|
||||
$versions .= "MySQL " . PMA_MYSQL_STR_VERSION;
|
||||
|
||||
$print_view_header = '';
|
||||
$print_view_header .= "<h1>" . __('SQL result') . "</h1>";
|
||||
$print_view_header .= "<p>";
|
||||
$print_view_header .= "<strong>" . __('Host:')
|
||||
. "</strong> $hostname<br />";
|
||||
$print_view_header .= "<strong>" . __('Database:') . "</strong> "
|
||||
. htmlspecialchars($db) . "<br />";
|
||||
$print_view_header .= "<strong>" . __('Generation Time:') . "</strong> "
|
||||
. PMA_Util::localisedDate() . "<br />";
|
||||
$print_view_header .= "<strong>" . __('Generated by:')
|
||||
. "</strong> $versions<br />";
|
||||
$print_view_header .= "<strong>" . __('SQL query:') . "</strong> "
|
||||
. htmlspecialchars($sql_query) . ";";
|
||||
if (isset($num_rows)) {
|
||||
$print_view_header .= "<br />";
|
||||
$print_view_header .= "<strong>" . __('Rows:') . "</strong> $num_rows";
|
||||
}
|
||||
$print_view_header .= "</p>";
|
||||
} else {
|
||||
$print_view_header = null;
|
||||
}
|
||||
|
||||
$versions = "phpMyAdmin " . PMA_VERSION;
|
||||
$versions .= " / ";
|
||||
$versions .= "MySQL " . PMA_MYSQL_STR_VERSION;
|
||||
|
||||
$header = '';
|
||||
$header .= "<h1>" . __('SQL result') . "</h1>";
|
||||
$header .= "<p>";
|
||||
$header .= "<strong>" . __('Host:') . "</strong> $hostname<br />";
|
||||
$header .= "<strong>" . __('Database:') . "</strong> "
|
||||
. htmlspecialchars($db) . "<br />";
|
||||
$header .= "<strong>" . __('Generation Time:') . "</strong> "
|
||||
. PMA_Util::localisedDate() . "<br />";
|
||||
$header .= "<strong>" . __('Generated by:') . "</strong> $versions<br />";
|
||||
$header .= "<strong>" . __('SQL query:') . "</strong> "
|
||||
. htmlspecialchars($sql_query) . ";";
|
||||
if (isset($num_rows)) {
|
||||
$header .= "<br />";
|
||||
$header .= "<strong>" . __('Rows:') . "</strong> $num_rows";
|
||||
}
|
||||
$header .= "</p>";
|
||||
|
||||
return $header;
|
||||
|
||||
return $print_view_header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTML for the profiling table and accompanying chart
|
||||
* Get the HTML for the profiling table and accompanying chart if profiling is set.
|
||||
* Otherwise returns null
|
||||
*
|
||||
* @param string $url_query the url query
|
||||
* @param string $pma_token the pma token
|
||||
* @param string $url_query url query
|
||||
* @param string $db current database
|
||||
* @param array $profiling_results array containing the profiling info
|
||||
*
|
||||
* @return string $profiling_table html for the profiling table and chart
|
||||
*/
|
||||
function PMA_getHtmlForProfilingChart($url_query, $pma_token, $profiling_results)
|
||||
function PMA_getHtmlForProfilingChart($url_query, $db, $profiling_results)
|
||||
{
|
||||
if (isset($profiling_results)) {
|
||||
$pma_token = $_SESSION[' PMA_token '];
|
||||
$url_query = (isset($url_query) ? $url_query : PMA_generate_common_url($db));
|
||||
|
||||
$profiling_table = '';
|
||||
$profiling_table .= '<fieldset><legend>' . __('Profiling')
|
||||
. '</legend>' . "\n";
|
||||
$profiling_table .= '<div style="float: left;">';
|
||||
$profiling_table .= '<h3>' . __('Detailed profile') . '</h3>';
|
||||
$profiling_table .= '<table id="profiletable"><thead>' . "\n";
|
||||
$profiling_table .= ' <tr>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Order')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('State')
|
||||
. PMA_Util::showMySQLDocu(
|
||||
'general-thread-states', 'general-thread-states'
|
||||
)
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' </tr></thead><tbody>' . "\n";
|
||||
list($detailed_table, $chart_json, $profiling_stats)
|
||||
= PMA_analyzeAndGetTableHtmlForProfilingResults($profiling_results);
|
||||
$profiling_table .= $detailed_table;
|
||||
$profiling_table .= '</tbody></table>' . "\n";
|
||||
$profiling_table .= '</div>';
|
||||
|
||||
$profiling_table .= '<div style="float: left; margin-left:10px;">';
|
||||
$profiling_table .= '<h3>' . __('Summary by state') . '</h3>';
|
||||
$profiling_table .= '<table id="profilesummarytable"><thead>' . "\n";
|
||||
$profiling_table .= ' <tr>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('State')
|
||||
. PMA_Util::showMySQLDocu(
|
||||
'general-thread-states', 'general-thread-states'
|
||||
)
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Total Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('% Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Calls')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('ø Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' </tr></thead><tbody>' . "\n";
|
||||
$profiling_table .= PMA_getTableHtmlForProfilingSummaryByState(
|
||||
$profiling_stats
|
||||
);
|
||||
$profiling_table .= '</tbody></table>' . "\n";
|
||||
|
||||
$profiling_table .= <<<EOT
|
||||
<script type="text/javascript">
|
||||
pma_token = '$pma_token';
|
||||
url_query = '$url_query';
|
||||
</script>
|
||||
EOT;
|
||||
$profiling_table .= "</div>";
|
||||
|
||||
//require_once 'libraries/chart.lib.php';
|
||||
$profiling_table .= '<div id="profilingChartData" style="display:none;">';
|
||||
$profiling_table .= json_encode($chart_json);
|
||||
$profiling_table .= '</div>';
|
||||
$profiling_table .= '<div id="profilingchart" style="display:none;">';
|
||||
$profiling_table .= '</div>';
|
||||
$profiling_table .= '<script type="text/javascript">';
|
||||
$profiling_table .= 'makeProfilingChart();';
|
||||
$profiling_table .= 'initProfilingTables();';
|
||||
$profiling_table .= '</script>';
|
||||
$profiling_table .= '</fieldset>' . "\n";
|
||||
} else {
|
||||
$profiling_table = null;
|
||||
}
|
||||
return $profiling_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get HTML for detailed profiling results table, profiling stats, and
|
||||
* $chart_json for displaying the chart.
|
||||
*
|
||||
* @param array $profiling_results profiling results
|
||||
* @return mixed
|
||||
*/
|
||||
function PMA_analyzeAndGetTableHtmlForProfilingResults(
|
||||
$profiling_results
|
||||
) {
|
||||
$profiling_stats = array(
|
||||
'total_time' => 0,
|
||||
'states' => array(),
|
||||
);
|
||||
$profiling_table = '';
|
||||
|
||||
$profiling_table .= '<fieldset><legend>' . __('Profiling') . '</legend>' . "\n";
|
||||
$profiling_table .= '<div style="float: left;">';
|
||||
$profiling_table .= '<h3>' . __('Detailed profile') . '</h3>';
|
||||
$profiling_table .= '<table id="profiletable"><thead>' . "\n";
|
||||
$profiling_table .= ' <tr>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Order')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('State')
|
||||
. PMA_Util::showMySQLDocu(
|
||||
'general-thread-states', 'general-thread-states'
|
||||
)
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' </tr></thead><tbody>' . "\n";
|
||||
|
||||
$chart_json = Array();
|
||||
$i = 1;
|
||||
$i = 1;
|
||||
$table = '';
|
||||
foreach ($profiling_results as $one_result) {
|
||||
if (isset($profiling_stats['states'][ucwords($one_result['Status'])])) {
|
||||
$profiling_stats['states'][ucwords($one_result['Status'])]['time']
|
||||
$states = $profiling_stats['states'];
|
||||
$states[ucwords($one_result['Status'])]['time']
|
||||
+= $one_result['Duration'];
|
||||
$profiling_stats['states'][ucwords($one_result['Status'])]['calls']++;
|
||||
$states[ucwords($one_result['Status'])]['calls']++;
|
||||
} else {
|
||||
$profiling_stats['states'][ucwords($one_result['Status'])] = array(
|
||||
'total_time' => $one_result['Duration'],
|
||||
@ -473,10 +554,11 @@ function PMA_getHtmlForProfilingChart($url_query, $pma_token, $profiling_results
|
||||
}
|
||||
$profiling_stats['total_time'] += $one_result['Duration'];
|
||||
|
||||
$profiling_table .= ' <tr>' . "\n";
|
||||
$profiling_table .= '<td>' . $i++ . '</td>' . "\n";
|
||||
$profiling_table .= '<td>' . ucwords($one_result['Status']) . '</td>' . "\n";
|
||||
$profiling_table .= '<td class="right">'
|
||||
$table .= ' <tr>' . "\n";
|
||||
$table .= '<td>' . $i++ . '</td>' . "\n";
|
||||
$table .= '<td>' . ucwords($one_result['Status'])
|
||||
. '</td>' . "\n";
|
||||
$table .= '<td class="right">'
|
||||
. (PMA_Util::formatNumber($one_result['Duration'], 3, 1))
|
||||
. 's<span style="display:none;" class="rawvalue">'
|
||||
. $one_result['Duration'] . '</span></td>' . "\n";
|
||||
@ -488,72 +570,44 @@ function PMA_getHtmlForProfilingChart($url_query, $pma_token, $profiling_results
|
||||
= $one_result['Duration'];
|
||||
}
|
||||
}
|
||||
return array($table, $chart_json, $profiling_stats);
|
||||
}
|
||||
|
||||
$profiling_table .= '</tbody></table>' . "\n";
|
||||
$profiling_table .= '</div>';
|
||||
|
||||
$profiling_table .= '<div style="float: left; margin-left:10px;">';
|
||||
$profiling_table .= '<h3>' . __('Summary by state') . '</h3>';
|
||||
$profiling_table .= '<table id="profilesummarytable"><thead>' . "\n";
|
||||
$profiling_table .= ' <tr>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('State')
|
||||
. PMA_Util::showMySQLDocu(
|
||||
'general-thread-states', 'general-thread-states'
|
||||
)
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Total Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('% Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Calls')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('ø Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' </tr></thead><tbody>' . "\n";
|
||||
/**
|
||||
* Function to get HTML for summary by state table
|
||||
*
|
||||
* @param array $profiling_stats profiling stats
|
||||
*
|
||||
* @return string $table html for the table
|
||||
*/
|
||||
function PMA_getTableHtmlForProfilingSummaryByState($profiling_stats)
|
||||
{
|
||||
$table = '';
|
||||
foreach ($profiling_stats['states'] as $name => $stats) {
|
||||
$profiling_table .= ' <tr>' . "\n";
|
||||
$profiling_table .= '<td>' . $name . '</td>' . "\n";
|
||||
$profiling_table .= '<td align="right">'
|
||||
$table .= ' <tr>' . "\n";
|
||||
$table .= '<td>' . $name . '</td>' . "\n";
|
||||
$table .= '<td align="right">'
|
||||
. PMA_Util::formatNumber($stats['total_time'], 3, 1)
|
||||
. 's<span style="display:none;" class="rawvalue">'
|
||||
. $stats['total_time'] . '</span></td>' . "\n";
|
||||
$profiling_table .= '<td align="right">'
|
||||
$table .= '<td align="right">'
|
||||
. PMA_Util::formatNumber(
|
||||
100 * ($stats['total_time'] / $profiling_stats['total_time']), 0, 2
|
||||
100 * ($stats['total_time'] / $profiling_stats['total_time']),
|
||||
0, 2
|
||||
)
|
||||
. '%</td>' . "\n";
|
||||
$table .= '<td align="right">' . $stats['calls'] . '</td>'
|
||||
. "\n";
|
||||
$table .= '<td align="right">'
|
||||
. PMA_Util::formatNumber(
|
||||
$stats['total_time'] / $stats['calls'], 3, 1
|
||||
)
|
||||
. '%</td>' . "\n";
|
||||
$profiling_table .= '<td align="right">' . $stats['calls'] . '</td>' . "\n";
|
||||
$profiling_table .= '<td align="right">'
|
||||
. PMA_Util::formatNumber($stats['total_time'] / $stats['calls'], 3, 1)
|
||||
. 's<span style="display:none;" class="rawvalue">'
|
||||
. number_format($stats['total_time'] / $stats['calls'], 8, '.', '')
|
||||
. '</span></td>' . "\n";
|
||||
$profiling_table .= ' </tr>' . "\n";
|
||||
$table .= ' </tr>' . "\n";
|
||||
}
|
||||
|
||||
$profiling_table .= '</tbody></table>' . "\n";
|
||||
|
||||
$profiling_table .= <<<EOT
|
||||
<script type="text/javascript">
|
||||
pma_token = '$pma_token';
|
||||
url_query = '$url_query';
|
||||
</script>
|
||||
EOT;
|
||||
$profiling_table .= "</div>";
|
||||
|
||||
//require_once 'libraries/chart.lib.php';
|
||||
$profiling_table .= '<div id="profilingChartData" style="display:none;">';
|
||||
$profiling_table .= json_encode($chart_json);
|
||||
$profiling_table .= '</div>';
|
||||
$profiling_table .= '<div id="profilingchart" style="display:none;">';
|
||||
$profiling_table .= '</div>';
|
||||
$profiling_table .= '<script type="text/javascript">';
|
||||
$profiling_table .= 'makeProfilingChart();';
|
||||
$profiling_table .= 'initProfilingTables();';
|
||||
$profiling_table .= '</script>';
|
||||
$profiling_table .= '</fieldset>' . "\n";
|
||||
|
||||
return $profiling_table;
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -653,56 +707,79 @@ function PMA_getHtmlForOptionsList($values, $selected_values)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML for the Bookmark form
|
||||
*
|
||||
* @param string $db the current database
|
||||
* @param string $goto goto page url
|
||||
* @param string $bkm_sql_query the query to be bookmarked
|
||||
* @param string $bkm_user the user creating the bookmark
|
||||
*
|
||||
* @return void
|
||||
* Function to get html for bookmark support if bookmarks are enabled. Else will
|
||||
* return null
|
||||
*
|
||||
* @param string $disp_mode display mode
|
||||
* @param bool $cfgBookmark confguration setting for bookmarking
|
||||
* @param string $sql_query sql query
|
||||
* @param string $db current database
|
||||
* @param string $table current table
|
||||
* @param string $complete_query complete query
|
||||
* @param string $bkm_user bookmarking user
|
||||
*
|
||||
* @return string $html
|
||||
*/
|
||||
function PMA_getHtmlForBookmark($db, $goto, $bkm_sql_query, $bkm_user)
|
||||
{
|
||||
$html = '<form action="sql.php" method="post"'
|
||||
. ' onsubmit="return ! emptyFormElements(this, \'bkm_fields[bkm_label]\');"'
|
||||
. ' id="bookmarkQueryForm">';
|
||||
$html .= PMA_generate_common_hidden_inputs();
|
||||
$html .= '<input type="hidden" name="goto" value="' . $goto . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_database]"'
|
||||
. ' value="' . htmlspecialchars($db) . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_user]"'
|
||||
. ' value="' . $bkm_user . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_sql_query]"' . ' value="'
|
||||
. $bkm_sql_query
|
||||
. '" />';
|
||||
$html .= '<fieldset>';
|
||||
$html .= '<legend>';
|
||||
$html .= PMA_Util::getIcon(
|
||||
'b_bookmark.png', __('Bookmark this SQL query'), true
|
||||
);
|
||||
$html .= '</legend>';
|
||||
$html .= '<div class="formelement">';
|
||||
$html .= '<label for="fields_label_">' . __('Label:') . '</label>';
|
||||
$html .= '<input type="text" id="fields_label_"'
|
||||
. ' name="bkm_fields[bkm_label]" value="" />';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="formelement">';
|
||||
$html .= '<input type="checkbox" name="bkm_all_users"'
|
||||
. ' id="bkm_all_users" value="true" />';
|
||||
$html .= '<label for="bkm_all_users">'
|
||||
. __('Let every user access this bookmark')
|
||||
. '</label>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="clearfloat"></div>';
|
||||
$html .= '</fieldset>';
|
||||
$html .= '<fieldset class="tblFooters">';
|
||||
$html .= '<input type="hidden" name="store_bkm" value="1" />';
|
||||
$html .= '<input type="submit"'
|
||||
. ' value="' . __('Bookmark this SQL query') . '" />';
|
||||
$html .= '</fieldset>';
|
||||
$html .= '</form>';
|
||||
|
||||
function PMA_getHtmlForBookmark($disp_mode, $cfgBookmark, $sql_query, $db, $table,
|
||||
$complete_query, $bkm_user
|
||||
) {
|
||||
if ($disp_mode[7] == '1'
|
||||
&& (! empty($cfgBookmark) && empty($_GET['id_bookmark']))
|
||||
&& ! empty($sql_query)
|
||||
) {
|
||||
$html = "\n";
|
||||
$goto = 'sql.php?'
|
||||
. PMA_generate_common_url($db, $table)
|
||||
. '&sql_query=' . urlencode($sql_query)
|
||||
. '&id_bookmark=1';
|
||||
$bkm_sql_query = urlencode(
|
||||
isset($complete_query) ? $complete_query : $sql_query
|
||||
);
|
||||
$html = '<form action="sql.php" method="post"'
|
||||
. ' onsubmit="return ! emptyFormElements(this,'
|
||||
. '\'bkm_fields[bkm_label]\');"'
|
||||
. ' id="bookmarkQueryForm">';
|
||||
$html .= PMA_generate_common_hidden_inputs();
|
||||
$html .= '<input type="hidden" name="goto" value="' . $goto . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_database]"'
|
||||
. ' value="' . htmlspecialchars($db) . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_user]"'
|
||||
. ' value="' . $bkm_user . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_sql_query]"'
|
||||
. ' value="'
|
||||
. $bkm_sql_query
|
||||
. '" />';
|
||||
$html .= '<fieldset>';
|
||||
$html .= '<legend>';
|
||||
$html .= PMA_Util::getIcon(
|
||||
'b_bookmark.png', __('Bookmark this SQL query'), true
|
||||
);
|
||||
$html .= '</legend>';
|
||||
$html .= '<div class="formelement">';
|
||||
$html .= '<label for="fields_label_">' . __('Label:') . '</label>';
|
||||
$html .= '<input type="text" id="fields_label_"'
|
||||
. ' name="bkm_fields[bkm_label]" value="" />';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="formelement">';
|
||||
$html .= '<input type="checkbox" name="bkm_all_users"'
|
||||
. ' id="bkm_all_users" value="true" />';
|
||||
$html .= '<label for="bkm_all_users">'
|
||||
. __('Let every user access this bookmark')
|
||||
. '</label>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="clearfloat"></div>';
|
||||
$html .= '</fieldset>';
|
||||
$html .= '<fieldset class="tblFooters">';
|
||||
$html .= '<input type="hidden" name="store_bkm" value="1" />';
|
||||
$html .= '<input type="submit"'
|
||||
. ' value="' . __('Bookmark this SQL query') . '" />';
|
||||
$html .= '</fieldset>';
|
||||
$html .= '</form>';
|
||||
|
||||
} else {
|
||||
$html = null;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
@ -1245,9 +1322,9 @@ function PMA_hasCurrentDbChanged($db)
|
||||
* @param String $db current database
|
||||
* @param String $table current table
|
||||
* @param String $dropped_column dropped column if any
|
||||
* @param bool $purge
|
||||
* @param array $extra_data
|
||||
*
|
||||
* @param bool $purge whether purge set or not
|
||||
* @param array $extra_data extra data
|
||||
*
|
||||
* @return array $extra_data
|
||||
*/
|
||||
function PMA_cleanupRelations($db, $table, $dropped_column, $purge, $extra_data)
|
||||
@ -1386,16 +1463,17 @@ function PMA_countQueryResults(
|
||||
|
||||
/**
|
||||
* Function to handle all aspects relating to executing the query
|
||||
*
|
||||
* @param array $analyzed_sql_results
|
||||
* @param String $full_sql_query full sql query
|
||||
* @param boolean $is_gotofile whether to go to a file
|
||||
* @param String $db current database
|
||||
* @param String $table current table
|
||||
* @param boolean $find_real_end whether to find the real end
|
||||
* @param String $import_text sql command
|
||||
* @param String $bkm_user bookmarking user
|
||||
*
|
||||
*
|
||||
* @param array $analyzed_sql_results analyzed sql results
|
||||
* @param String $full_sql_query full sql query
|
||||
* @param boolean $is_gotofile whether to go to a file
|
||||
* @param String $db current database
|
||||
* @param String $table current table
|
||||
* @param boolean $find_real_end whether to find the real end
|
||||
* @param String $import_text sql command
|
||||
* @param String $bkm_user bookmarking user
|
||||
* @param array $extra_data extra data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofile,
|
||||
@ -1422,8 +1500,8 @@ function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofil
|
||||
// If there are no errors and bookmarklabel was given,
|
||||
// store the query as a bookmark
|
||||
if (! empty($_POST['bkm_label']) && ! empty($import_text)) {
|
||||
PMA_storeTheQueryAsBookmark($db, $bkm_user,
|
||||
$import_text, $_POST['bkm_label'],
|
||||
PMA_storeTheQueryAsBookmark(
|
||||
$db, $bkm_user, $import_text, $_POST['bkm_label'],
|
||||
isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null
|
||||
);
|
||||
} // end store bookmarks
|
||||
@ -1445,8 +1523,8 @@ function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofil
|
||||
$analyzed_sql_results, isset($find_real_end) ? $find_real_end : null
|
||||
);
|
||||
|
||||
$unlim_num_rows = PMA_countQueryResults($num_rows,
|
||||
$analyzed_sql_results['is_select'], $justBrowsing, $db,
|
||||
$unlim_num_rows = PMA_countQueryResults(
|
||||
$num_rows, $analyzed_sql_results['is_select'], $justBrowsing, $db,
|
||||
$table, $analyzed_sql_results['parsed_sql'], $analyzed_sql_results
|
||||
);
|
||||
|
||||
@ -1500,8 +1578,8 @@ function PMA_deleteTransformationInfo($db, $table, $analyzed_sql)
|
||||
*
|
||||
* @return string $message
|
||||
*/
|
||||
function PMA_getMessageForNoRowsReturned(
|
||||
$message_to_show, $analyzed_sql_results, $num_rows
|
||||
function PMA_getMessageForNoRowsReturned($message_to_show, $analyzed_sql_results,
|
||||
$num_rows
|
||||
) {
|
||||
if ($analyzed_sql_results['is_delete']) {
|
||||
$message = PMA_Message::getMessageForDeletedRows($num_rows);
|
||||
@ -1570,8 +1648,8 @@ function PMA_getMessageForNoRowsReturned(
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_sendAjaxResponseForNoResultsReturned(
|
||||
$message, $analyzed_sql, $displayResultsObject, $showSql, $extra_data
|
||||
function PMA_sendAjaxResponseForNoResultsReturned($message, $analyzed_sql,
|
||||
$displayResultsObject, $showSql, $extra_data
|
||||
) {
|
||||
/**
|
||||
* @todo find a better way to make getMessage() in Header.class.php
|
||||
@ -1643,12 +1721,247 @@ function PMA_sendResponseForNoResultsReturned($analyzed_sql_results, $db, $table
|
||||
$num_rows
|
||||
);
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
PMA_sendAjaxResponseForNoResultsReturned($message,
|
||||
$analyzed_sql_results['analyzed_sql'],
|
||||
PMA_sendAjaxResponseForNoResultsReturned(
|
||||
$message, $analyzed_sql_results['analyzed_sql'],
|
||||
$displayResultsObject, $cfg['ShowSQL'],
|
||||
isset($extra_data) ? $extra_data : null
|
||||
);
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to send response for ajax grid edit
|
||||
*
|
||||
* @param object $result result of the executed query
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_sendResponseForGridEdit($result)
|
||||
{
|
||||
$row = $GLOBALS['dbi']->fetchRow($result);
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addJSON('value', $row[0]);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for the sql query results div
|
||||
*
|
||||
* @param string $previous_update_query_html html for the previously executed query
|
||||
* @param string $profiling_chart_html html for profiling
|
||||
* @param object $missing_unique_column_msg message for the missing unique column
|
||||
* @param object $bookmark_created_msg message for bookmark creation
|
||||
* @param string $table_html html for the table for displaying sql
|
||||
* results
|
||||
* @param string $indexes_problems_html html for displaying errors in indexes
|
||||
* @param string $bookmark_support_html html for displaying bookmark form
|
||||
* @param string $print_button_html html for the print button in printview
|
||||
*
|
||||
* @return string $html_output
|
||||
*/
|
||||
function PMA_getHtmlForSqlQueryResults($previous_update_query_html,
|
||||
$profiling_chart_html, $missing_unique_column_msg, $bookmark_created_msg,
|
||||
$table_html, $indexes_problems_html, $bookmark_support_html, $print_button_html
|
||||
) {
|
||||
//begin the sqlqueryresults div here. container div
|
||||
$html_output = '<div id="sqlqueryresults" class="ajax">';
|
||||
$html_output .= isset($previous_update_query_html)
|
||||
? $previous_update_query_html : '';
|
||||
$html_output .= isset($profiling_chart_html) ? $profiling_chart_html : '';
|
||||
$html_output .= isset($missing_unique_column_msg)
|
||||
? $missing_unique_column_msg->getDisplay() : '';
|
||||
$html_output .= isset($bookmark_created_msg)
|
||||
? $bookmark_created_msg->getDisplay() : '';
|
||||
$html_output .= $table_html;
|
||||
$html_output .= isset($indexes_problems_html) ? $indexes_problems_html : '';
|
||||
$html_output .= isset($bookmark_support_html) ? $bookmark_support_html : '';
|
||||
$html_output .= isset($print_button_html) ? $print_button_html : '';
|
||||
$html_output .= '</div>'; // end sqlqueryresults div
|
||||
|
||||
return $html_output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a message for successful creation of a bookmark or null if a bookmark
|
||||
* was not created
|
||||
*
|
||||
* @return object $bookmark_created_msg
|
||||
*/
|
||||
function PMA_getBookmarkCreatedMessage()
|
||||
{
|
||||
if (isset($_GET['label'])) {
|
||||
$bookmark_created_msg = PMA_message::success(__('Bookmark %s created'));
|
||||
$bookmark_created_msg->addParam($_GET['label']);
|
||||
} else {
|
||||
$bookmark_created_msg = null;
|
||||
}
|
||||
|
||||
return $bookmark_created_msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for the sql query results table
|
||||
*
|
||||
* @param array $sql_data sql data
|
||||
* @param object $displayResultsObject instance of DisplayResult.class
|
||||
* @param string $db current database
|
||||
* @param string $goto goto page url
|
||||
* @param string $pmaThemeImage theme image uri
|
||||
* @param string $text_dir text directory
|
||||
* @param string $url_query url query
|
||||
* @param string $disp_mode display mode
|
||||
* @param string $sql_limit_to_append sql limit to append
|
||||
* @param bool $editable whether the result table is editable or not
|
||||
* @param int $unlim_num_rows unlimited number of rows
|
||||
* @param int $num_rows number of rows
|
||||
* @param bool $showtable whether to show table or not
|
||||
* @param object $result result of the executed query
|
||||
* @param int $querytime query execution time
|
||||
* @param array $analyzed_sql_results analyzed sql results
|
||||
* @param bool $is_procedure whether it is a procedure call or not
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function PMA_getHtmlForSqlQueryResultsTable($sql_data, $displayResultsObject, $db,
|
||||
$goto, $pmaThemeImage, $text_dir, $url_query, $disp_mode, $sql_limit_to_append,
|
||||
$editable, $unlim_num_rows, $num_rows, $showtable, $result, $querytime,
|
||||
$analyzed_sql_results, $is_procedure
|
||||
) {
|
||||
$printview = isset($_REQUEST['printview']) ? $_REQUEST['printview'] : null;
|
||||
if (! empty($sql_data) && ($sql_data['valid_queries'] > 1) || $is_procedure) {
|
||||
$_SESSION['is_multi_query'] = true;
|
||||
$table_html = PMA_getTableHtmlForMultipleQueries(
|
||||
$displayResultsObject, $db, $sql_data, $goto,
|
||||
$pmaThemeImage, $text_dir, $printview, $url_query,
|
||||
$disp_mode, $sql_limit_to_append, $editable
|
||||
);
|
||||
} else {
|
||||
if (isset($result) && $result) {
|
||||
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
|
||||
$fields_cnt = count($fields_meta);
|
||||
}
|
||||
$_SESSION['is_multi_query'] = false;
|
||||
$displayResultsObject->setProperties(
|
||||
$unlim_num_rows, $fields_meta, $analyzed_sql_results['is_count'],
|
||||
$analyzed_sql_results['is_export'], $analyzed_sql_results['is_func'],
|
||||
$analyzed_sql_results['is_analyse'], $num_rows,
|
||||
$fields_cnt, $querytime, $pmaThemeImage, $text_dir,
|
||||
$analyzed_sql_results['is_maint'], $analyzed_sql_results['is_explain'],
|
||||
$analyzed_sql_results['is_show'], $showtable, $printview, $url_query,
|
||||
$editable
|
||||
);
|
||||
|
||||
$table_html = $displayResultsObject->getTable(
|
||||
$result, $disp_mode, $analyzed_sql_results['analyzed_sql']
|
||||
);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
}
|
||||
|
||||
return $table_html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for the previous query if there is such. If not will return
|
||||
* null
|
||||
*
|
||||
* @param string $disp_query display query
|
||||
* @param bool $showSql whether to show sql
|
||||
* @param array $sql_data sql data
|
||||
* @param string $disp_message display message
|
||||
*
|
||||
* @return string $previous_update_query_html
|
||||
*/
|
||||
function PMA_getHtmlForPreviousUpdateQuery($disp_query, $showSql, $sql_data,
|
||||
$disp_message
|
||||
) {
|
||||
// previous update query (from tbl_replace)
|
||||
if (isset($disp_query) && ($showSql == true) && empty($sql_data)) {
|
||||
$previous_update_query_html = PMA_Util::getMessage(
|
||||
$disp_message, $disp_query, 'success'
|
||||
);
|
||||
} else {
|
||||
$previous_update_query_html = null;
|
||||
}
|
||||
|
||||
return $previous_update_query_html;
|
||||
}
|
||||
|
||||
/**
|
||||
* To get the message if a column index is missing. If not will return null
|
||||
*
|
||||
* @param string $table current table
|
||||
* @param string $db current database
|
||||
* @param boolean $editable whether the results table can be editable or not
|
||||
* @param string $disp_mode display mode
|
||||
*
|
||||
* @return object $message
|
||||
*/
|
||||
function PMA_getMessageIfMissingColumnIndex($table, $db, $editable, $disp_mode)
|
||||
{
|
||||
if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) || !$editable)) {
|
||||
$missing_unique_column_msg = PMA_message::notice(
|
||||
__(
|
||||
'Table %s does not contain a unique column.'
|
||||
. ' Grid edit, checkbox, Edit, Copy and Delete features'
|
||||
. ' are not available.'
|
||||
)
|
||||
);
|
||||
$missing_unique_column_msg->addParam($table);
|
||||
} else {
|
||||
$missing_unique_column_msg = null;
|
||||
}
|
||||
|
||||
return $missing_unique_column_msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html to display problems in indexes
|
||||
*
|
||||
* @param string $query_type query type
|
||||
* @param boolean $selected selected
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_getHtmlForIndexesProblems($query_type, $selected)
|
||||
{
|
||||
// BEGIN INDEX CHECK See if indexes should be checked.
|
||||
if (isset($query_type)
|
||||
&& $query_type == 'check_tbl'
|
||||
&& isset($selected)
|
||||
&& is_array($selected)
|
||||
) {
|
||||
$indexes_problems_html = '';
|
||||
foreach ($selected as $idx => $tbl_name) {
|
||||
$check = PMA_Index::findDuplicates($tbl_name, $db);
|
||||
if (! empty($check)) {
|
||||
$indexes_problems_html .= sprintf(
|
||||
__('Problems with indexes of table `%s`'), $tbl_name
|
||||
);
|
||||
$indexes_problems_html .= $check;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$indexes_problems_html = null;
|
||||
}
|
||||
|
||||
return $indexes_problems_html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the html for the print button in printview
|
||||
*
|
||||
* @return string $print_button_html html for the print button
|
||||
*/
|
||||
function PMA_getHtmlForPrintButton()
|
||||
{
|
||||
// Do print the page if required
|
||||
if (isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
|
||||
$print_button_html = PMA_Util::getButton();
|
||||
} else {
|
||||
$print_button_html = null;
|
||||
}
|
||||
|
||||
return $print_button_html;
|
||||
}
|
||||
?>
|
||||
|
||||
@ -993,6 +993,7 @@ function PMA_SQP_analyze($arr)
|
||||
* ['queryflags']['is_func'] = 1; for the presence of SUM|AVG|STD|STDDEV
|
||||
* |MIN|MAX|BIT_OR|BIT_AND
|
||||
* ['queryflags']['is_count'] = 1; for the presence of SELECT COUNT
|
||||
* ['queryflags']['is_procedure'] = 1; for the presence of CALL
|
||||
*
|
||||
* query clauses
|
||||
* -------------
|
||||
@ -1721,6 +1722,11 @@ function PMA_SQP_analyze($arr)
|
||||
if ($upper_data == 'OFFSET') {
|
||||
$subresult['queryflags']['offset'] = 1;
|
||||
}
|
||||
|
||||
// for the presence of CALL
|
||||
if ($upper_data == 'CALL') {
|
||||
$subresult['queryflags']['is_procedure'] = 1;
|
||||
}
|
||||
|
||||
// if this is a real SELECT...FROM
|
||||
if ($upper_data == 'FROM'
|
||||
|
||||
362
sql.php
362
sql.php
@ -130,8 +130,8 @@ require_once 'libraries/parse_analyze.inc.php';
|
||||
* into account this case.
|
||||
*/
|
||||
if (PMA_hasNoRightsToDropDatabase(
|
||||
$analyzed_sql_results, $cfg['AllowUserDropDatabase'], $is_superuser)
|
||||
) {
|
||||
$analyzed_sql_results, $cfg['AllowUserDropDatabase'], $is_superuser
|
||||
)) {
|
||||
PMA_Util::mysqlDie(
|
||||
__('"DROP DATABASE" statements are disabled.'),
|
||||
'',
|
||||
@ -186,7 +186,6 @@ if (PMA_isRememberSortingOrder($analyzed_sql_results)) {
|
||||
PMA_handleSortOrder($db, $table, $analyzed_sql, $full_sql_query);
|
||||
}
|
||||
|
||||
$sql_limit_to_append = '';
|
||||
// Do append a "LIMIT" clause?
|
||||
if (PMA_isAppendLimitClause($analyzed_sql_results)) {
|
||||
list($sql_limit_to_append,
|
||||
@ -194,17 +193,8 @@ if (PMA_isAppendLimitClause($analyzed_sql_results)) {
|
||||
) = PMA_appendLimitClause(
|
||||
$full_sql_query, $analyzed_sql, isset($display_query)
|
||||
);
|
||||
}
|
||||
|
||||
// Since multiple query execution is anyway handled,
|
||||
// ignore the WHERE clause of the first sql statement
|
||||
// which might contain a phrase like 'call '
|
||||
if (preg_match("/\bcall\b/i", $full_sql_query)
|
||||
&& empty($analyzed_sql[0]['where_clause'])
|
||||
) {
|
||||
$is_procedure = true;
|
||||
} else {
|
||||
$is_procedure = false;
|
||||
$sql_limit_to_append = '';
|
||||
}
|
||||
|
||||
$reload = PMA_hasCurrentDbChanged($db);
|
||||
@ -222,167 +212,33 @@ list($result, $num_rows, $unlim_num_rows, $profiling_results,
|
||||
|
||||
// No rows returned -> move back to the calling page
|
||||
if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
|
||||
PMA_sendResponseForNoResultsReturned($analyzed_sql_results, $db, $table,
|
||||
PMA_sendResponseForNoResultsReturned(
|
||||
$analyzed_sql_results, $db, $table,
|
||||
isset($message_to_show) ? $message_to_show : null,
|
||||
$num_rows, $displayResultsObject, $extra_data, $cfg
|
||||
);
|
||||
|
||||
} else {
|
||||
$html_output='';
|
||||
// At least one row is returned -> displays a table with results
|
||||
//If we are retrieving the full value of a truncated field or the original
|
||||
// If we are retrieving the full value of a truncated field or the original
|
||||
// value of a transformed field, show it here and exit
|
||||
if ($GLOBALS['grid_edit'] == true) {
|
||||
$row = $GLOBALS['dbi']->fetchRow($result);
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addJSON('value', $row[0]);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['ajax_request']) && isset($_REQUEST['table_maintenance'])) {
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('makegrid.js');
|
||||
$scripts->addFile('sql.js');
|
||||
|
||||
// Gets the list of fields properties
|
||||
if (isset($result) && $result) {
|
||||
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
|
||||
$fields_cnt = count($fields_meta);
|
||||
}
|
||||
|
||||
if (empty($disp_mode)) {
|
||||
// see the "PMA_setDisplayMode()" function in
|
||||
// libraries/DisplayResults.class.php
|
||||
$disp_mode = 'urdr111101';
|
||||
}
|
||||
|
||||
// hide edit and delete links for information_schema
|
||||
if ($GLOBALS['dbi']->isSystemSchema($db)) {
|
||||
$disp_mode = 'nnnn110111';
|
||||
}
|
||||
|
||||
if (isset($message)) {
|
||||
$message = PMA_Message::success($message);
|
||||
$html_output .= PMA_Util::getMessage(
|
||||
$message, $GLOBALS['sql_query'], 'success'
|
||||
);
|
||||
}
|
||||
|
||||
// Should be initialized these parameters before parsing
|
||||
$showtable = isset($showtable) ? $showtable : null;
|
||||
$printview = isset($_REQUEST['printview']) ? $_REQUEST['printview'] : null;
|
||||
$url_query = isset($url_query) ? $url_query : null;
|
||||
|
||||
if (!empty($sql_data) && ($sql_data['valid_queries'] > 1)) {
|
||||
|
||||
$_SESSION['is_multi_query'] = true;
|
||||
$html_output .= getTableHtmlForMultipleQueries(
|
||||
$displayResultsObject, $db, $sql_data, $goto,
|
||||
$pmaThemeImage, $text_dir, $printview, $url_query,
|
||||
$disp_mode, $sql_limit_to_append, false
|
||||
);
|
||||
} else {
|
||||
$_SESSION['is_multi_query'] = false;
|
||||
$displayResultsObject->setProperties(
|
||||
$unlim_num_rows, $fields_meta, $is_count, $is_export, $is_func,
|
||||
$is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage,
|
||||
$text_dir, $is_maint, $is_explain, $is_show, $showtable,
|
||||
$printview, $url_query, false
|
||||
);
|
||||
|
||||
$html_output .= $displayResultsObject->getTable(
|
||||
$result, $disp_mode, $analyzed_sql
|
||||
);
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addHTML($html_output);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
// Displays the headers
|
||||
if (isset($show_query)) {
|
||||
unset($show_query);
|
||||
}
|
||||
if (isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
|
||||
PMA_Util::checkParameters(array('db', 'full_sql_query'));
|
||||
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$header->enablePrintView();
|
||||
|
||||
$html_output .= PMA_getHtmlForPrintViewHeader(
|
||||
$db, $full_sql_query, $num_rows
|
||||
);
|
||||
} else {
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('makegrid.js');
|
||||
$scripts->addFile('sql.js');
|
||||
|
||||
unset($message);
|
||||
|
||||
if (! $GLOBALS['is_ajax_request']) {
|
||||
if (strlen($table)) {
|
||||
include 'libraries/tbl_common.inc.php';
|
||||
$url_query .= '&goto=tbl_sql.php&back=tbl_sql.php';
|
||||
include 'libraries/tbl_info.inc.php';
|
||||
} elseif (strlen($db)) {
|
||||
include 'libraries/db_common.inc.php';
|
||||
include 'libraries/db_info.inc.php';
|
||||
} else {
|
||||
include 'libraries/server_common.inc.php';
|
||||
}
|
||||
} else {
|
||||
//we don't need to buffer the output in getMessage here.
|
||||
//set a global variable and check against it in the function
|
||||
$GLOBALS['buffer_message'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($db)) {
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
if ($_REQUEST['grid_edit'] == true) {
|
||||
PMA_sendResponseForGridEdit($result);
|
||||
}
|
||||
|
||||
// Gets the list of fields properties
|
||||
if (isset($result) && $result) {
|
||||
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
|
||||
$fields_cnt = count($fields_meta);
|
||||
}
|
||||
|
||||
//begin the sqlqueryresults div here. container div
|
||||
$html_output .= '<div id="sqlqueryresults"';
|
||||
$html_output .= ' class="ajax"';
|
||||
$html_output .= '>';
|
||||
|
||||
// Display previous update query (from tbl_replace)
|
||||
if (isset($disp_query) && ($cfg['ShowSQL'] == true) && empty($sql_data)) {
|
||||
$html_output .= PMA_Util::getMessage($disp_message, $disp_query, 'success');
|
||||
}
|
||||
|
||||
if (isset($profiling_results)) {
|
||||
// pma_token/url_query needed for chart export
|
||||
$token = $_SESSION[' PMA_token '];
|
||||
$url = (isset($url_query) ? $url_query : PMA_generate_common_url($db));
|
||||
|
||||
$html_output .= PMA_getHtmlForProfilingChart(
|
||||
$url, $token, $profiling_results
|
||||
);
|
||||
}
|
||||
|
||||
// Displays the results in a table
|
||||
if (empty($disp_mode)) {
|
||||
// see the "PMA_setDisplayMode()" function in
|
||||
// libraries/DisplayResults.class.php
|
||||
$disp_mode = 'urdr111101';
|
||||
}
|
||||
|
||||
$has_unique = PMA_resultSetContainsUniqueKey(
|
||||
$db, $table, $fields_meta
|
||||
);
|
||||
|
||||
|
||||
// Should be initialized these parameters before parsing
|
||||
$showtable = isset($showtable) ? $showtable : null;
|
||||
$url_query = isset($url_query) ? $url_query : null;
|
||||
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$scripts = $header->getScripts();
|
||||
|
||||
// hide edit and delete links:
|
||||
// - for information_schema
|
||||
// - if the result set does not contain all the columns of a unique key
|
||||
@ -391,103 +247,107 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
|
||||
= $justBrowsing
|
||||
&& trim($analyzed_sql[0]['select_expr_clause']) == '*'
|
||||
&& PMA_Table::isUpdatableView($db, $table);
|
||||
|
||||
$has_unique = PMA_resultSetContainsUniqueKey(
|
||||
$db, $table, $fields_meta
|
||||
);
|
||||
|
||||
$editable = $has_unique || $updatableView;
|
||||
|
||||
// Displays the results in a table
|
||||
if (empty($disp_mode)) {
|
||||
// see the "PMA_setDisplayMode()" function in
|
||||
// libraries/DisplayResults.class.php
|
||||
$disp_mode = 'urdr111101';
|
||||
}
|
||||
if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) || !$editable)) {
|
||||
$disp_mode = 'nnnn110111';
|
||||
$msg = PMA_message::notice(
|
||||
__(
|
||||
'Table %s does not contain a unique column.'
|
||||
. ' Grid edit, checkbox, Edit, Copy and Delete features'
|
||||
. ' are not available.'
|
||||
)
|
||||
);
|
||||
$msg->addParam($table);
|
||||
$html_output .= $msg->getDisplay();
|
||||
}
|
||||
|
||||
if (isset($_GET['label'])) {
|
||||
$msg = PMA_message::success(__('Bookmark %s created'));
|
||||
$msg->addParam($_GET['label']);
|
||||
$html_output .= $msg->getDisplay();
|
||||
if ( isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
|
||||
$disp_mode = 'nnnn000000';
|
||||
}
|
||||
|
||||
// Should be initialized these parameters before parsing
|
||||
$showtable = isset($showtable) ? $showtable : null;
|
||||
$printview = isset($_REQUEST['printview']) ? $_REQUEST['printview'] : null;
|
||||
$url_query = isset($url_query) ? $url_query : null;
|
||||
|
||||
if (! empty($sql_data) && ($sql_data['valid_queries'] > 1) || $is_procedure) {
|
||||
|
||||
$_SESSION['is_multi_query'] = true;
|
||||
$html_output .= getTableHtmlForMultipleQueries(
|
||||
$displayResultsObject, $db, $sql_data, $goto,
|
||||
$pmaThemeImage, $text_dir, $printview, $url_query,
|
||||
$disp_mode, $sql_limit_to_append, $editable
|
||||
);
|
||||
} else {
|
||||
$_SESSION['is_multi_query'] = false;
|
||||
$displayResultsObject->setProperties(
|
||||
$unlim_num_rows, $fields_meta, $is_count, $is_export, $is_func,
|
||||
$is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage,
|
||||
$text_dir, $is_maint, $is_explain, $is_show, $showtable,
|
||||
$printview, $url_query, $editable
|
||||
);
|
||||
|
||||
$html_output .= $displayResultsObject->getTable(
|
||||
$result, $disp_mode, $analyzed_sql
|
||||
);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
}
|
||||
|
||||
// BEGIN INDEX CHECK See if indexes should be checked.
|
||||
if (isset($query_type)
|
||||
&& $query_type == 'check_tbl'
|
||||
&& isset($selected)
|
||||
&& is_array($selected)
|
||||
) {
|
||||
foreach ($selected as $idx => $tbl_name) {
|
||||
$check = PMA_Index::findDuplicates($tbl_name, $db);
|
||||
if (! empty($check)) {
|
||||
$html_output .= sprintf(
|
||||
__('Problems with indexes of table `%s`'), $tbl_name
|
||||
);
|
||||
$html_output .= $check;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['table_maintenance'])) {
|
||||
$scripts->addFile('makegrid.js');
|
||||
$scripts->addFile('sql.js');
|
||||
if (isset($message)) {
|
||||
$message = PMA_Message::success($message);
|
||||
$table_maintenance_html = PMA_Util::getMessage(
|
||||
$message, $GLOBALS['sql_query'], 'success'
|
||||
);
|
||||
}
|
||||
} // End INDEX CHECK
|
||||
|
||||
// Bookmark support if required
|
||||
if ($disp_mode[7] == '1'
|
||||
&& (! empty($cfg['Bookmark']) && empty($_GET['id_bookmark']))
|
||||
&& ! empty($sql_query)
|
||||
) {
|
||||
$html_output .= "\n";
|
||||
$goto = 'sql.php?'
|
||||
. PMA_generate_common_url($db, $table)
|
||||
. '&sql_query=' . urlencode($sql_query)
|
||||
. '&id_bookmark=1';
|
||||
$bkm_sql_query = urlencode(
|
||||
isset($complete_query) ? $complete_query : $sql_query
|
||||
$table_maintenance_html .= PMA_getHtmlForSqlQueryResultsTable(
|
||||
isset($sql_data) ? $sql_data : null, $displayResultsObject, $db, $goto,
|
||||
$pmaThemeImage, $text_dir, $url_query, $disp_mode, $sql_limit_to_append,
|
||||
false, $unlim_num_rows, $num_rows, $showtable, $result, $querytime,
|
||||
$analyzed_sql_results, false
|
||||
);
|
||||
$html_output .= PMA_getHtmlForBookmark(
|
||||
$db, $goto, $bkm_sql_query, $cfg['Bookmark']['user']
|
||||
);
|
||||
} // end bookmark support
|
||||
if (empty($sql_data) || ($sql_data['valid_queries'] = 1)) {
|
||||
$response->addHTML($table_maintenance_html);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
// Do print the page if required
|
||||
if (isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
|
||||
$html_output .= PMA_Util::getButton();
|
||||
} // end print case
|
||||
$html_output .= '</div>'; // end sqlqueryresults div
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addHTML($html_output);
|
||||
if (!isset($_REQUEST['printview']) || $_REQUEST['printview'] != '1') {
|
||||
$scripts->addFile('makegrid.js');
|
||||
$scripts->addFile('sql.js');
|
||||
unset($message);
|
||||
//we don't need to buffer the output in getMessage here.
|
||||
//set a global variable and check against it in the function
|
||||
$GLOBALS['buffer_message'] = false;
|
||||
}
|
||||
|
||||
$print_view_header_html = PMA_getHtmlForPrintViewHeader(
|
||||
$db, $full_sql_query, $num_rows
|
||||
);
|
||||
|
||||
$previous_update_query_html = PMA_getHtmlForPreviousUpdateQuery(
|
||||
isset($disp_query) ? $disp_query : null,
|
||||
$cfg['ShowSQL'], isset($sql_data) ? $sql_data : null,
|
||||
isset($disp_message) ? $disp_message : null
|
||||
);
|
||||
|
||||
$profiling_chart_html = PMA_getHtmlForProfilingChart(
|
||||
$disp_mode, $db, isset($profiling_results) ? $profiling_results : null
|
||||
);
|
||||
|
||||
$missing_unique_column_msg = PMA_getMessageIfMissingColumnIndex(
|
||||
$table, $db, $editable, $disp_mode
|
||||
);
|
||||
|
||||
$bookmark_created_msg = PMA_getBookmarkCreatedMessage();
|
||||
|
||||
$table_html = PMA_getHtmlForSqlQueryResultsTable(
|
||||
isset($sql_data) ? $sql_data : null, $displayResultsObject, $db, $goto,
|
||||
$pmaThemeImage, $text_dir, $url_query, $disp_mode, $sql_limit_to_append,
|
||||
$editable, $unlim_num_rows, $num_rows, $showtable, $result, $querytime,
|
||||
$analyzed_sql_results, $is_procedure
|
||||
);
|
||||
|
||||
$indexes_problems_html = PMA_getHtmlForIndexesProblems(
|
||||
isset($query_type) ? $query_type : null,
|
||||
isset($selected) ? $selected : null
|
||||
);
|
||||
|
||||
$bookmark_support_html = PMA_getHtmlForBookmark(
|
||||
$disp_mode, isset($cfg['Bookmark']) ? $cfg['Bookmark'] : '', $sql_query,
|
||||
$db, $table, isset($complete_query) ? $complete_query : $sql_query,
|
||||
$cfg['Bookmark']['user']
|
||||
);
|
||||
|
||||
$print_button_html = PMA_getHtmlForPrintButton();
|
||||
|
||||
$html_output = isset($table_maintenance_html) ? $table_maintenance_html : '';
|
||||
|
||||
$html_output .= isset($print_view_header_html) ? $print_view_header_html : '';
|
||||
|
||||
$html_output .= PMA_getHtmlForSqlQueryResults(
|
||||
$previous_update_query_html, $profiling_chart_html,
|
||||
$missing_unique_column_msg, $bookmark_created_msg,
|
||||
$table_html, $indexes_problems_html, $bookmark_support_html,
|
||||
$print_button_html
|
||||
);
|
||||
|
||||
$response->addHTML($html_output);
|
||||
} // end rows returned
|
||||
|
||||
$_SESSION['is_multi_query'] = false;
|
||||
|
||||
|
||||
if (! isset($_REQUEST['table_maintenance'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user