Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1226790de0
@ -214,7 +214,6 @@ if (is_array($foreignData['disp_row'])) {
|
||||
$val_ordered_current_equals_data = false;
|
||||
$key_ordered_current_equals_data = false;
|
||||
foreach ($keys as $key_ordered_current_row => $value) {
|
||||
//for ($i = 0; $i < $count; $i++) {
|
||||
$hcount++;
|
||||
|
||||
if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) {
|
||||
|
||||
@ -124,9 +124,11 @@ foreach ($tables as $table) {
|
||||
// and SHOW CREATE TABLE says NOT NULL
|
||||
// http://bugs.mysql.com/20910.
|
||||
|
||||
$show_create_table_query = 'SHOW CREATE TABLE '
|
||||
. PMA_CommonFunctions::getInstance()->backquote($db) . '.'
|
||||
. PMA_CommonFunctions::getInstance()->backquote($table);
|
||||
$show_create_table = PMA_DBI_fetch_value(
|
||||
'SHOW CREATE TABLE ' . PMA_CommonFunctions::getInstance()->backquote($db) . '.' . PMA_CommonFunctions::getInstance()->backquote($table),
|
||||
0, 1
|
||||
$show_create_table_query, 0, 1
|
||||
);
|
||||
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
|
||||
}
|
||||
@ -185,7 +187,7 @@ foreach ($tables as $table) {
|
||||
}
|
||||
$extracted_columnspec
|
||||
= PMA_CommonFunctions::getInstance()->extractColumnSpec($row['Type']);
|
||||
|
||||
|
||||
// reformat mysql query output
|
||||
// set or enum types: slashes single quotes inside options
|
||||
if ('set' == $extracted_columnspec['type'] || 'enum' == $extracted_columnspec['type']) {
|
||||
|
||||
@ -33,8 +33,9 @@ $common_functions = PMA_CommonFunctions::getInstance();
|
||||
/**
|
||||
* Rename/move or copy database
|
||||
*/
|
||||
if (strlen($db) && (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_copy']))) {
|
||||
|
||||
if (strlen($db)
|
||||
&& (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_copy']))
|
||||
) {
|
||||
if (! empty($_REQUEST['db_rename'])) {
|
||||
$move = true;
|
||||
} else {
|
||||
@ -70,7 +71,7 @@ if (strlen($db) && (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_cop
|
||||
// remove all foreign key constraints, otherwise we can get errors
|
||||
$export_sql_plugin = PMA_getPlugin(
|
||||
"export",
|
||||
"sql",
|
||||
"sql",
|
||||
'libraries/plugins/export/',
|
||||
array(
|
||||
'single_table' => isset($single_table),
|
||||
@ -82,7 +83,7 @@ if (strlen($db) && (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_cop
|
||||
$tables_full, $export_sql_plugin, $move, $db
|
||||
);
|
||||
|
||||
$views = PMA_getViewsAndCreateSqlViewStandIn(
|
||||
$views = PMA_getViewsAndCreateSqlViewStandIn(
|
||||
$tables_full, $export_sql_plugin, $db
|
||||
);
|
||||
|
||||
@ -113,7 +114,7 @@ if (strlen($db) && (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_cop
|
||||
|
||||
// Duplicate the bookmarks for this db (done once for each db)
|
||||
PMA_duplicateBookmarks($_error, $db);
|
||||
|
||||
|
||||
if (! $_error && $move) {
|
||||
/**
|
||||
* cleanup pmadb stuff for this db
|
||||
@ -140,7 +141,9 @@ if (strlen($db) && (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_cop
|
||||
if (! $_error && $move) {
|
||||
$db = $_REQUEST['newname'];
|
||||
} elseif (! $_error) {
|
||||
if (isset($_REQUEST['switch_to_new']) && $_REQUEST['switch_to_new'] == 'true') {
|
||||
if (isset($_REQUEST['switch_to_new'])
|
||||
&& $_REQUEST['switch_to_new'] == 'true'
|
||||
) {
|
||||
$GLOBALS['PMA_Config']->setCookie('pma_switch_to_new', 'true');
|
||||
$db = $_REQUEST['newname'];
|
||||
} else {
|
||||
@ -213,7 +216,7 @@ if (!$is_information_schema) {
|
||||
*/
|
||||
$response->addHTML(PMA_getHtmlForDatabaseComment($db));
|
||||
}
|
||||
|
||||
|
||||
$response->addHTML('<div class="operations_half_width">');
|
||||
ob_start();
|
||||
include 'libraries/display_create_table.lib.php';
|
||||
@ -230,7 +233,8 @@ if (!$is_information_schema) {
|
||||
}
|
||||
|
||||
// Drop link if allowed
|
||||
// Don't even try to drop information_schema. You won't be able to. Believe me. You won't.
|
||||
// Don't even try to drop information_schema.
|
||||
// You won't be able to. Believe me. You won't.
|
||||
// Don't allow to easily drop mysql database, RFE #1327514.
|
||||
if (($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase'])
|
||||
&& ! $db_is_information_schema
|
||||
|
||||
14
db_qbe.php
14
db_qbe.php
@ -54,13 +54,15 @@ if ($cfgRelation['designerwork']) {
|
||||
array('query' => 1)
|
||||
)
|
||||
);
|
||||
$response->addHTML(PMA_Message::notice(
|
||||
sprintf(
|
||||
__('Switch to %svisual builder%s'),
|
||||
'<a href="' . $url . '">',
|
||||
'</a>'
|
||||
$response->addHTML(
|
||||
PMA_Message::notice(
|
||||
sprintf(
|
||||
__('Switch to %svisual builder%s'),
|
||||
'<a href="' . $url . '">',
|
||||
'</a>'
|
||||
)
|
||||
)
|
||||
));//->display();
|
||||
);
|
||||
}
|
||||
$response->addHTML($db_qbe->getSelectionForm($cfgRelation));
|
||||
?>
|
||||
|
||||
@ -117,7 +117,8 @@ if (isset($_REQUEST['sort_order'])) {
|
||||
$_url_params['sort_order'] = $_REQUEST['sort_order'];
|
||||
}
|
||||
|
||||
$response->addHTML($common_functions->getListNavigator(
|
||||
$response->addHTML(
|
||||
$common_functions->getListNavigator(
|
||||
$total_num_tables, $pos, $_url_params, 'db_structure.php',
|
||||
'frame_content', $GLOBALS['cfg']['MaxTableList']
|
||||
)
|
||||
@ -126,7 +127,7 @@ $response->addHTML($common_functions->getListNavigator(
|
||||
// tables form
|
||||
$response->addHTML(
|
||||
'<form method="post" action="db_structure.php" '
|
||||
. 'name="tablesForm" id="tablesForm">'
|
||||
. 'name="tablesForm" id="tablesForm">'
|
||||
);
|
||||
|
||||
$response->addHTML(PMA_generate_common_hidden_inputs($db));
|
||||
@ -158,16 +159,17 @@ foreach ($tables as $keyname => $current_table) {
|
||||
$drop_query = '';
|
||||
$drop_message = '';
|
||||
$overhead = '';
|
||||
|
||||
|
||||
$table_is_view = false;
|
||||
$table_encoded = urlencode($current_table['TABLE_NAME']);
|
||||
// Sets parameters for links
|
||||
$tbl_url_query = $url_query . '&table=' . $table_encoded;
|
||||
// do not list the previous table's size info for a view
|
||||
|
||||
|
||||
list($current_table, $formatted_size, $unit, $formatted_overhead,
|
||||
$overhead_unit, $overhead_size, $table_is_view, $sum_size)
|
||||
= PMA_getStuffForEngineTypeTable($current_table, $db_is_information_schema,
|
||||
= PMA_getStuffForEngineTypeTable(
|
||||
$current_table, $db_is_information_schema,
|
||||
$is_show_stats, $table_is_view, $sum_size, $overhead_size
|
||||
);
|
||||
|
||||
@ -186,8 +188,10 @@ foreach ($tables as $keyname => $current_table) {
|
||||
if ($is_show_stats) {
|
||||
if ($formatted_overhead != '') {
|
||||
$overhead = '<a href="tbl_structure.php?'
|
||||
. $tbl_url_query . '#showusage"><span>' . $formatted_overhead
|
||||
. '</span> <span class="unit">' . $overhead_unit . '</span></a>' . "\n";
|
||||
. $tbl_url_query . '#showusage">'
|
||||
. '<span>' . $formatted_overhead . '</span>'
|
||||
. '<span class="unit">' . $overhead_unit . '</span>'
|
||||
. '</a>' . "\n";
|
||||
$overhead_check .=
|
||||
"markAllRows('row_tbl_" . ($i + 1) . "');";
|
||||
} else {
|
||||
@ -240,14 +244,13 @@ foreach ($tables as $keyname => $current_table) {
|
||||
* the code easier to read without this operator.
|
||||
*/
|
||||
list($browse_table, $search_table, $browse_table_label, $empty_table,
|
||||
$tracking_icon
|
||||
) = PMA_getHtmlForActionLinks(
|
||||
$tracking_icon) = PMA_getHtmlForActionLinks(
|
||||
$current_table, $table_is_view, $tbl_url_query,
|
||||
$titles, $truename, $db_is_information_schema, $url_query
|
||||
);
|
||||
|
||||
|
||||
if (! $db_is_information_schema) {
|
||||
list($drop_query, $drop_message)
|
||||
list($drop_query, $drop_message)
|
||||
= PMA_getTableDropQueryAndMessage($table_is_view, $current_table);
|
||||
}
|
||||
|
||||
@ -258,9 +261,9 @@ foreach ($tables as $keyname => $current_table) {
|
||||
$row_count = 1;
|
||||
$odd_row = true;
|
||||
|
||||
$response->addHTML('</tr>'
|
||||
. '</tbody>'
|
||||
. '</table>');
|
||||
$response->addHTML(
|
||||
'</tr></tbody></table>'
|
||||
);
|
||||
|
||||
$response->addHTML(PMA_TableHeader(false, $server_slave_status));
|
||||
}
|
||||
@ -268,7 +271,7 @@ foreach ($tables as $keyname => $current_table) {
|
||||
list($do, $ignored) = PMA_getServerSlaveStatus(
|
||||
$server_slave_status, $truename
|
||||
);
|
||||
|
||||
|
||||
list($html_output, $odd_row) = PMA_getHtmlForStructureTableRow(
|
||||
$i, $odd_row, $table_is_view, $current_table, $checked,
|
||||
$browse_table_label, $tracking_icon, $server_slave_status,
|
||||
@ -281,7 +284,7 @@ foreach ($tables as $keyname => $current_table) {
|
||||
$is_show_stats, $ignored, $do, $colspan_for_structure
|
||||
);
|
||||
$response->addHTML($html_output);
|
||||
|
||||
|
||||
} // end foreach
|
||||
|
||||
// Show Summary
|
||||
@ -296,8 +299,9 @@ $response->addHTML(
|
||||
$response->addHTML('</table>');
|
||||
//check all
|
||||
$response->addHTML(
|
||||
PMA_getHtmlForCheckAllTables($pmaThemeImage, $text_dir,
|
||||
$overhead_check, $db_is_information_schema, $hidden_fields
|
||||
PMA_getHtmlForCheckAllTables(
|
||||
$pmaThemeImage, $text_dir, $overhead_check,
|
||||
$db_is_information_schema, $hidden_fields
|
||||
)
|
||||
);
|
||||
$response->addHTML('</form>'); //end of form
|
||||
|
||||
@ -171,8 +171,7 @@ foreach ($table_list as $key => $value) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// If $value is a table.
|
||||
} else {
|
||||
} else { // If $value is a table.
|
||||
if (PMA_Tracker::getVersion($GLOBALS['db'], $value['Name']) == -1) {
|
||||
$my_tables[] = $value['Name'];
|
||||
}
|
||||
|
||||
38
export.php
38
export.php
@ -324,7 +324,8 @@ if ($asfile) {
|
||||
$filename = PMA_sanitizeFilename($filename);
|
||||
|
||||
// Grab basic dump extension and mime type
|
||||
// Check if the user already added extension; get the substring where the extension would be if it was included
|
||||
// Check if the user already added extension;
|
||||
// get the substring where the extension would be if it was included
|
||||
$extension_start_pos = strlen($filename) - strlen(
|
||||
$export_plugin->getProperties()->getExtension()
|
||||
) - 1;
|
||||
@ -359,22 +360,21 @@ if ($save_on_server) {
|
||||
|| ($quick_export
|
||||
&& $_REQUEST['quick_export_onserverover'] != 'saveitover'))
|
||||
) {
|
||||
$message = PMA_Message::error(__(
|
||||
'File %s already exists on server, change filename or check'
|
||||
. ' overwrite option.'
|
||||
));
|
||||
$message = PMA_Message::error(
|
||||
__('File %s already exists on server, change filename or check overwrite option.')
|
||||
);
|
||||
$message->addParam($save_filename);
|
||||
} else {
|
||||
if (is_file($save_filename) && ! is_writable($save_filename)) {
|
||||
$message = PMA_Message::error(__(
|
||||
'The web server does not have permission to save the file %s.'
|
||||
));
|
||||
$message = PMA_Message::error(
|
||||
__('The web server does not have permission to save the file %s.')
|
||||
);
|
||||
$message->addParam($save_filename);
|
||||
} else {
|
||||
if (! $file_handle = @fopen($save_filename, 'w')) {
|
||||
$message = PMA_Message::error(__(
|
||||
'The web server does not have permission to save the file %s.'
|
||||
));
|
||||
$message = PMA_Message::error(
|
||||
__('The web server does not have permission to save the file %s.')
|
||||
);
|
||||
$message->addParam($save_filename);
|
||||
}
|
||||
}
|
||||
@ -624,7 +624,9 @@ do {
|
||||
}
|
||||
// now export the triggers (needs to be done after the data because
|
||||
// triggers can modify already imported tables)
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
|
||||
) {
|
||||
if (! $export_plugin->exportStructure(
|
||||
$db, $table, $crlf, $err_url,
|
||||
'triggers', $export_type,
|
||||
@ -636,7 +638,9 @@ do {
|
||||
}
|
||||
foreach ($views as $view) {
|
||||
// no data export for a view
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
|
||||
) {
|
||||
if (! $export_plugin->exportStructure(
|
||||
$db, $view, $crlf, $err_url,
|
||||
'create_view', $export_type,
|
||||
@ -665,7 +669,9 @@ do {
|
||||
}
|
||||
|
||||
$is_view = PMA_Table::isView($db, $table);
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
|
||||
if ($GLOBALS[$what . '_structure_or_data'] == 'structure'
|
||||
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data'
|
||||
) {
|
||||
if (! $export_plugin->exportStructure(
|
||||
$db, $table, $crlf, $err_url,
|
||||
$is_view ? 'create_view' : 'create_table', $export_type,
|
||||
@ -693,9 +699,7 @@ do {
|
||||
$local_query = 'SELECT * FROM ' . $common_functions->backquote($db)
|
||||
. '.' . $common_functions->backquote($table) . $add_query;
|
||||
}
|
||||
if (! $export_plugin->exportData($db, $table, $crlf, $err_url,
|
||||
$local_query
|
||||
)) {
|
||||
if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,7 +301,7 @@ if (! empty($local_import_file) && ! empty($cfg['UploadDir'])) {
|
||||
|
||||
$import_file = $common_functions->userDir($cfg['UploadDir'])
|
||||
. $local_import_file;
|
||||
|
||||
|
||||
} elseif (empty($import_file) || ! is_uploaded_file($import_file)) {
|
||||
$import_file = 'none';
|
||||
}
|
||||
@ -530,7 +530,9 @@ if (strlen($sql_query) <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
|
||||
// There was an error?
|
||||
if (isset($my_die)) {
|
||||
foreach ($my_die AS $key => $die) {
|
||||
$common_functions->mysqlDie($die['error'], $die['sql'], '', $err_url, $error);
|
||||
$common_functions->mysqlDie(
|
||||
$die['error'], $die['sql'], '', $err_url, $error
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -85,8 +85,8 @@ $header->disableMenu();
|
||||
$header->setBodyId('body_leftFrame');
|
||||
$scripts = $header->getScripts();
|
||||
$scripts->addFile('navigation.js');
|
||||
$scripts->addCode('
|
||||
// INIT PMA_setFrameSize
|
||||
$scripts->addCode(
|
||||
'// INIT PMA_setFrameSize
|
||||
var onloadCnt = 0;
|
||||
var onLoadHandler = window.onload;
|
||||
var resizeHandler = window.onresize;
|
||||
@ -113,8 +113,8 @@ $scripts->addCode('
|
||||
) {
|
||||
PMA_saveFrameSize();
|
||||
}
|
||||
};
|
||||
');
|
||||
};'
|
||||
);
|
||||
|
||||
require 'libraries/navigation_header.inc.php';
|
||||
|
||||
@ -339,7 +339,7 @@ function PMA_displayDbList($ext_dblist, $offset, $count)
|
||||
{
|
||||
global $element_counter, $img_minus, $img_plus, $href_left,
|
||||
$db_start, $common_url_query;
|
||||
|
||||
|
||||
$common_functions = PMA_CommonFunctions::getInstance();
|
||||
|
||||
// get table list, for all databases
|
||||
@ -530,9 +530,9 @@ function PMA_displayTableList(
|
||||
$tables, $visible = false,
|
||||
$tab_group_full = '', $table_db = ''
|
||||
) {
|
||||
|
||||
|
||||
$common_functions = PMA_CommonFunctions::getInstance();
|
||||
|
||||
|
||||
if (! is_array($tables) || count($tables) === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ $header->disableMenu();
|
||||
<br>
|
||||
<div>
|
||||
<?php
|
||||
if (!empty($message)) {
|
||||
if (! empty($message)) {
|
||||
$message->display();
|
||||
}
|
||||
?>
|
||||
|
||||
@ -37,9 +37,9 @@ if ($common_functions->isForeignKeySupported($type_T1)
|
||||
|
||||
if (isset($existrel_foreign[$F2]['constraint'])) {
|
||||
$upd_query = 'ALTER TABLE ' . $common_functions->backquote($DB2)
|
||||
. '.' . $common_functions->backquote($T2) . ' DROP FOREIGN KEY '
|
||||
. $common_functions->backquote($existrel_foreign[$F2]['constraint'])
|
||||
. ';';
|
||||
. '.' . $common_functions->backquote($T2) . ' DROP FOREIGN KEY '
|
||||
. $common_functions->backquote($existrel_foreign[$F2]['constraint'])
|
||||
. ';';
|
||||
$upd_rs = PMA_DBI_query($upd_query);
|
||||
} else {
|
||||
// there can be an internal relation even if InnoDB
|
||||
|
||||
@ -76,10 +76,10 @@ function PMD_err_sav()
|
||||
}
|
||||
|
||||
if (! empty($die_save_pos)) {
|
||||
header("Content-Type: text/xml; charset=utf-8");
|
||||
header("Cache-Control: no-cache");
|
||||
?>
|
||||
<root act='save_pos' return='<?php echo __('Modifications have been saved'); ?>'></root>
|
||||
<?php
|
||||
header("Content-Type: text/xml; charset=utf-8");
|
||||
header("Cache-Control: no-cache");
|
||||
?>
|
||||
<root act='save_pos' return='<?php echo __('Modifications have been saved'); ?>'></root>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
@ -137,7 +137,8 @@ if ($pos > 0) {
|
||||
$this_url_params['pos'] = $pos - $GLOBALS['cfg']['MaxRows'];
|
||||
}
|
||||
|
||||
echo '<a href="server_binlog.php' . PMA_generate_common_url($this_url_params) . '"';
|
||||
echo '<a href="server_binlog.php'
|
||||
. PMA_generate_common_url($this_url_params) . '"';
|
||||
if ($GLOBALS['cfg']['NavigationBarIconic']) {
|
||||
echo ' title="' . _pgettext('Previous page', 'Previous') . '">';
|
||||
} else {
|
||||
|
||||
@ -113,7 +113,13 @@ if ((isset($_REQUEST['drop_selected_dbs']) || isset($_REQUEST['query_type']))
|
||||
} else {
|
||||
$number_of_databases = 0;
|
||||
}
|
||||
$message = PMA_Message::success(_ngettext('%1$d database has been dropped successfully.', '%1$d databases have been dropped successfully.', $number_of_databases));
|
||||
$message = PMA_Message::success(
|
||||
_ngettext(
|
||||
'%1$d database has been dropped successfully.',
|
||||
'%1$d databases have been dropped successfully.',
|
||||
$number_of_databases
|
||||
)
|
||||
);
|
||||
$message->addParam($number_of_databases);
|
||||
}
|
||||
}
|
||||
@ -207,10 +213,10 @@ if ($databases_count > 0) {
|
||||
$_url_params['sort_by'] = $stat_name;
|
||||
$_url_params['sort_order'] = ($sort_by == $stat_name && $sort_order == 'desc') ? 'asc' : 'desc';
|
||||
echo ' <th' . $colspan . '>'
|
||||
.'<a href="server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
|
||||
.' ' . $stat['disp_name'] . "\n"
|
||||
.($sort_by == $stat_name ? ' ' . $common_functions->getImage('s_' . $sort_order . '.png', ($sort_order == 'asc' ? __('Ascending') : __('Descending'))) . "\n" : '')
|
||||
.' </a></th>' . "\n";
|
||||
. '<a href="server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
|
||||
. ' ' . $stat['disp_name'] . "\n"
|
||||
. ($sort_by == $stat_name ? ' ' . $common_functions->getImage('s_' . $sort_order . '.png', ($sort_order == 'asc' ? __('Ascending') : __('Descending'))) . "\n" : '')
|
||||
. ' </a></th>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,7 +248,15 @@ if ($databases_count > 0) {
|
||||
echo '<tr class="' . $tr_class . '">' . "\n";
|
||||
$odd_row = ! $odd_row;
|
||||
|
||||
list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, (isset($checkall) ? $checkall : ''), $url_query, $column_order, $replication_types, $replication_info);
|
||||
list($column_order, $generated_html) = PMA_buildHtmlForDb(
|
||||
$current,
|
||||
$is_superuser,
|
||||
(isset($checkall) ? $checkall : ''),
|
||||
$url_query,
|
||||
$column_order,
|
||||
$replication_types,
|
||||
$replication_info
|
||||
);
|
||||
|
||||
echo $generated_html;
|
||||
|
||||
@ -294,21 +308,35 @@ if ($databases_count > 0) {
|
||||
unset($column_order, $stat_name, $stat, $databases, $table_columns);
|
||||
|
||||
if ($is_superuser || $cfg['AllowUserDropDatabase']) {
|
||||
$common_url_query = PMA_generate_common_url(array('sort_by' => $sort_by, 'sort_order' => $sort_order, 'dbstats' => $dbstats));
|
||||
echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
|
||||
$common_url_query = PMA_generate_common_url(
|
||||
array(
|
||||
'sort_by' => $sort_by,
|
||||
'sort_order' => $sort_order,
|
||||
'dbstats' => $dbstats
|
||||
)
|
||||
);
|
||||
echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png"'
|
||||
. ' width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
|
||||
. '<input type="checkbox" id="checkall" title="' . __('Check All') . '" /> '
|
||||
. '<label for="checkall">' . __('Check All') . '</label> '
|
||||
. '<i style="margin-left: 2em">' . __('With selected:') . '</i>' . "\n";
|
||||
echo $common_functions->getButtonOrImage('drop_selected_dbs', 'mult_submit' . ($cfg['AjaxEnable'] ? ' ajax' : ''), 'drop_selected_dbs', __('Drop'), 'b_deltbl.png');
|
||||
echo $common_functions->getButtonOrImage(
|
||||
'drop_selected_dbs',
|
||||
'mult_submit' . ($cfg['AjaxEnable'] ? ' ajax' : ''),
|
||||
'drop_selected_dbs',
|
||||
__('Drop'), 'b_deltbl.png'
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($dbstats)) {
|
||||
echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
|
||||
echo ' <a href="server_databases.php?' . $url_query . '&dbstats=1"'
|
||||
.' title="' . __('Enable Statistics') . '">' . "\n"
|
||||
.' ' . __('Enable Statistics');
|
||||
echo '<a href="server_databases.php?' . $url_query . '&dbstats=1"'
|
||||
. ' title="' . __('Enable Statistics') . '">' . "\n"
|
||||
. ' ' . __('Enable Statistics');
|
||||
echo '</a></strong><br />' . "\n";
|
||||
PMA_Message::notice(__('Note: Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server.'))->display();
|
||||
PMA_Message::notice(
|
||||
__('Note: Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server.')
|
||||
)->display();
|
||||
echo '</li>' . "\n" . '</ul>' . "\n";
|
||||
}
|
||||
echo '</form>';
|
||||
|
||||
@ -146,9 +146,9 @@ if (isset($dbname)) {
|
||||
if (! $is_superuser) {
|
||||
$response->addHTML(
|
||||
'<h2>' . "\n"
|
||||
. $common_functions->getIcon('b_usrlist.png')
|
||||
. __('Privileges') . "\n"
|
||||
. '</h2>' . "\n"
|
||||
. $common_functions->getIcon('b_usrlist.png')
|
||||
. __('Privileges') . "\n"
|
||||
. '</h2>' . "\n"
|
||||
);
|
||||
$response->addHTML(PMA_Message::error(__('No Privileges'))->getDisplay());
|
||||
exit;
|
||||
|
||||
@ -40,7 +40,8 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
$varValue = PMA_DBI_fetch_single_row(
|
||||
'SHOW GLOBAL VARIABLES WHERE Variable_name="'
|
||||
. $common_functions->sqlAddSlashes($_REQUEST['varName']) . '";', 'NUM'
|
||||
. $common_functions->sqlAddSlashes($_REQUEST['varName']) . '";',
|
||||
'NUM'
|
||||
);
|
||||
if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3])
|
||||
&& $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte'
|
||||
@ -167,12 +168,16 @@ foreach ($serverVars as $name => $value) {
|
||||
function formatVariable($name, $value)
|
||||
{
|
||||
global $VARIABLE_DOC_LINKS;
|
||||
|
||||
|
||||
$common_functions = PMA_CommonFunctions::getInstance();
|
||||
|
||||
if (is_numeric($value)) {
|
||||
if (isset($VARIABLE_DOC_LINKS[$name][3]) && $VARIABLE_DOC_LINKS[$name][3]=='byte') {
|
||||
return '<abbr title="'.$common_functions->formatNumber($value, 0).'">'.implode(' ', $common_functions->formatByteDown($value, 3, 3)).'</abbr>';
|
||||
if (isset($VARIABLE_DOC_LINKS[$name][3])
|
||||
&& $VARIABLE_DOC_LINKS[$name][3]=='byte'
|
||||
) {
|
||||
return '<abbr title="' . $common_functions->formatNumber($value, 0) . '">'
|
||||
. implode(' ', $common_functions->formatByteDown($value, 3, 3))
|
||||
. '</abbr>';
|
||||
} else {
|
||||
return $common_functions->formatNumber($value, 0);
|
||||
}
|
||||
|
||||
216
sql.php
216
sql.php
@ -96,8 +96,8 @@ if (! empty($goto)) {
|
||||
|
||||
if (! isset($err_url)) {
|
||||
$err_url = (! empty($back) ? $back : $goto)
|
||||
. '?' . PMA_generate_common_url($db)
|
||||
. ((strpos(' ' . $goto, 'db_') != 1 && strlen($table)) ? '&table=' . urlencode($table) : '');
|
||||
. '?' . PMA_generate_common_url($db)
|
||||
. ((strpos(' ' . $goto, 'db_') != 1 && strlen($table)) ? '&table=' . urlencode($table) : '');
|
||||
} // end if
|
||||
|
||||
// Coming from a bookmark dialog
|
||||
@ -118,12 +118,16 @@ if (isset($fields['dbase'])) {
|
||||
* This doesn't seem to be the right place to do this, but I can't think of any
|
||||
* better place either.
|
||||
*/
|
||||
if (isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_values'] == true) {
|
||||
|
||||
if (isset($_REQUEST['get_relational_values'])
|
||||
&& $_REQUEST['get_relational_values'] == true
|
||||
) {
|
||||
$column = $_REQUEST['column'];
|
||||
$foreigners = PMA_getForeigners($db, $table, $column);
|
||||
|
||||
$display_field = PMA_getDisplayField($foreigners[$column]['foreign_db'], $foreigners[$column]['foreign_table']);
|
||||
$display_field = PMA_getDisplayField(
|
||||
$foreigners[$column]['foreign_db'],
|
||||
$foreigners[$column]['foreign_table']
|
||||
);
|
||||
|
||||
$foreignData = PMA_getForeignData($foreigners, $column, false, '', '');
|
||||
|
||||
@ -138,18 +142,29 @@ if (isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_value
|
||||
$curr_value = $_REQUEST['curr_value'];
|
||||
}
|
||||
if ($foreignData['disp_row'] == null) {
|
||||
//Handle the case when number of values is more than $cfg['ForeignKeyMaxLimit']
|
||||
//Handle the case when number of values
|
||||
//is more than $cfg['ForeignKeyMaxLimit']
|
||||
$_url_params = array(
|
||||
'db' => $db,
|
||||
'table' => $table,
|
||||
'field' => $column
|
||||
);
|
||||
|
||||
$dropdown = '<span class="curr_value">' . htmlspecialchars($_REQUEST['curr_value']) . '</span> <a href="browse_foreigners.php' . PMA_generate_common_url($_url_params) . '"'
|
||||
. ' target="_blank" class="browse_foreign" '
|
||||
.'>' . __('Browse foreign values') . '</a>';
|
||||
$dropdown = '<span class="curr_value">'
|
||||
. htmlspecialchars($_REQUEST['curr_value'])
|
||||
. '</span>'
|
||||
. '<a href="browse_foreigners.php' . PMA_generate_common_url($_url_params) . '"'
|
||||
. ' target="_blank" class="browse_foreign" ' .'>'
|
||||
. __('Browse foreign values')
|
||||
. '</a>';
|
||||
} else {
|
||||
$dropdown = PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $curr_value, $cfg['ForeignKeyMaxLimit']);
|
||||
$dropdown = PMA_foreignDropdown(
|
||||
$foreignData['disp_row'],
|
||||
$foreignData['foreign_field'],
|
||||
$foreignData['foreign_display'],
|
||||
$curr_value,
|
||||
$cfg['ForeignKeyMaxLimit']
|
||||
);
|
||||
$dropdown = '<select>' . $dropdown . '</select>';
|
||||
}
|
||||
|
||||
@ -166,7 +181,9 @@ if (isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_value
|
||||
if (isset($_REQUEST['get_enum_values']) && $_REQUEST['get_enum_values'] == true) {
|
||||
$field_info_query = PMA_DBI_get_columns_sql($db, $table, $_REQUEST['column']);
|
||||
|
||||
$field_info_result = PMA_DBI_fetch_result($field_info_query, null, null, null, PMA_DBI_QUERY_STORE);
|
||||
$field_info_result = PMA_DBI_fetch_result(
|
||||
$field_info_query, null, null, null, PMA_DBI_QUERY_STORE
|
||||
);
|
||||
|
||||
$values = $common_functions->parseEnumSetValues($field_info_result[0]['Type']);
|
||||
|
||||
@ -192,7 +209,9 @@ if (isset($_REQUEST['get_enum_values']) && $_REQUEST['get_enum_values'] == true)
|
||||
if (isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) {
|
||||
$field_info_query = PMA_DBI_get_columns_sql($db, $table, $_REQUEST['column']);
|
||||
|
||||
$field_info_result = PMA_DBI_fetch_result($field_info_query, null, null, null, PMA_DBI_QUERY_STORE);
|
||||
$field_info_result = PMA_DBI_fetch_result(
|
||||
$field_info_query, null, null, null, PMA_DBI_QUERY_STORE
|
||||
);
|
||||
|
||||
$selected_values = explode(',', $_REQUEST['curr_value']);
|
||||
|
||||
@ -208,7 +227,8 @@ if (isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) {
|
||||
}
|
||||
|
||||
$select_size = (sizeof($values) > 10) ? 10 : sizeof($values);
|
||||
$select = '<select multiple="multiple" size="' . $select_size . '">' . $select . '</select>';
|
||||
$select = '<select multiple="multiple" size="' . $select_size . '">'
|
||||
. $select . '</select>';
|
||||
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addJSON('select', $select);
|
||||
@ -226,9 +246,10 @@ if (isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) {
|
||||
if (isset($_REQUEST['col_order'])) {
|
||||
$col_order = explode(',', $_REQUEST['col_order']);
|
||||
$retval = $pmatable->setUiProp(
|
||||
PMA_Table::PROP_COLUMN_ORDER, $col_order,
|
||||
PMA_Table::PROP_COLUMN_ORDER,
|
||||
$col_order,
|
||||
$_REQUEST['table_create_time']
|
||||
);
|
||||
);
|
||||
if (gettype($retval) != 'boolean') {
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->isSuccess(false);
|
||||
@ -243,7 +264,7 @@ if (isset($_REQUEST['set_col_prefs']) && $_REQUEST['set_col_prefs'] == true) {
|
||||
$retval = $pmatable->setUiProp(
|
||||
PMA_Table::PROP_COLUMN_VISIB, $col_visib,
|
||||
$_REQUEST['table_create_time']
|
||||
);
|
||||
);
|
||||
if (gettype($retval) != 'boolean') {
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->isSuccess(false);
|
||||
@ -271,10 +292,8 @@ if (empty($sql_query) && strlen($table) && strlen($db)) {
|
||||
|
||||
if (! empty($book_sql_query)) {
|
||||
$GLOBALS['using_bookmark_message'] = PMA_message::notice(
|
||||
__(
|
||||
'Using bookmark "%s" as default browse query.'
|
||||
)
|
||||
);
|
||||
__('Using bookmark "%s" as default browse query.')
|
||||
);
|
||||
$GLOBALS['using_bookmark_message']->addParam($table);
|
||||
$GLOBALS['using_bookmark_message']->addMessage(
|
||||
$common_functions->showDocu('faq6_22')
|
||||
@ -340,11 +359,9 @@ if (isset($find_real_end) && $find_real_end) {
|
||||
*/
|
||||
if (isset($store_bkm)) {
|
||||
PMA_Bookmark_save(
|
||||
$fields, (isset($bkm_all_users)
|
||||
&& $bkm_all_users == 'true'
|
||||
? true
|
||||
: false)
|
||||
);
|
||||
$fields,
|
||||
(isset($bkm_all_users) && $bkm_all_users == 'true' ? true : false)
|
||||
);
|
||||
// go back to sql.php to redisplay query; do not use & in this case:
|
||||
PMA_sendHeaderLocation(
|
||||
$cfg['PmaAbsoluteUri'] . $goto . '&label=' . $fields['label']
|
||||
@ -414,9 +431,9 @@ if (! $cfg['Confirm']
|
||||
if ($do_confirm) {
|
||||
$stripped_sql_query = $sql_query;
|
||||
if ($is_drop_database) {
|
||||
echo '<h1 class="error">' . __(
|
||||
'You are about to DESTROY a complete database!'
|
||||
) . '</h1>';
|
||||
echo '<h1 class="error">'
|
||||
. __('You are about to DESTROY a complete database!')
|
||||
. '</h1>';
|
||||
}
|
||||
echo '<form action="sql.php" method="post">' . "\n"
|
||||
.PMA_generate_common_hidden_inputs($db, $table);
|
||||
@ -500,8 +517,11 @@ if (($_SESSION['tmp_user_values']['max_rows'] != 'all')
|
||||
&& ! isset($analyzed_sql[0]['queryflags']['offset'])
|
||||
&& empty($analyzed_sql[0]['limit_clause'])
|
||||
) {
|
||||
|
||||
$full_sql_query = PMA_getSqlWithLimitClause($full_sql_query, $analyzed_sql, $sql_limit_to_append);
|
||||
$full_sql_query = PMA_getSqlWithLimitClause(
|
||||
$full_sql_query,
|
||||
$analyzed_sql,
|
||||
$sql_limit_to_append
|
||||
);
|
||||
|
||||
/**
|
||||
* @todo pretty printing of this modified query
|
||||
@ -516,7 +536,8 @@ if (($_SESSION['tmp_user_values']['max_rows'] != 'all')
|
||||
) {
|
||||
$analyzed_display_query = PMA_SQP_analyze(PMA_SQP_parse($display_query));
|
||||
$display_query = $analyzed_display_query[0]['section_before_limit']
|
||||
. "\n" . $sql_limit_to_append . $analyzed_display_query[0]['section_after_limit'];
|
||||
. "\n" . $sql_limit_to_append
|
||||
. $analyzed_display_query[0]['section_after_limit'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -583,9 +604,9 @@ if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) {
|
||||
*/
|
||||
include '' . PMA_securePath($goto);
|
||||
} else {
|
||||
$full_err_url = (preg_match('@^(db|tbl)_@', $err_url))
|
||||
? $err_url . '&show_query=1&sql_query=' . urlencode($sql_query)
|
||||
: $err_url;
|
||||
$full_err_url = preg_match('@^(db|tbl)_@', $err_url)
|
||||
? $err_url . '&show_query=1&sql_query=' . urlencode($sql_query)
|
||||
: $err_url;
|
||||
$common_functions->mysqlDie($error, $full_sql_query, '', $full_err_url);
|
||||
}
|
||||
exit;
|
||||
@ -696,10 +717,19 @@ if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) {
|
||||
// take the left part, could be:
|
||||
// SELECT
|
||||
// (SELECT
|
||||
$count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] + 1);
|
||||
$count_query = PMA_SQP_formatHtml(
|
||||
$parsed_sql,
|
||||
'query_only',
|
||||
0,
|
||||
$analyzed_sql[0]['position_of_first_select'] + 1
|
||||
);
|
||||
$count_query .= ' SQL_CALC_FOUND_ROWS ';
|
||||
// add everything that was after the first SELECT
|
||||
$count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select'] + 1);
|
||||
$count_query .= PMA_SQP_formatHtml(
|
||||
$parsed_sql,
|
||||
'query_only',
|
||||
$analyzed_sql[0]['position_of_first_select'] + 1
|
||||
);
|
||||
// ensure there is no semicolon at the end of the
|
||||
// count query because we'll probably add
|
||||
// a LIMIT 1 clause after it
|
||||
@ -756,7 +786,11 @@ if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) {
|
||||
} // end if ($purge)
|
||||
|
||||
// If a column gets dropped, do relation magic.
|
||||
if (isset($dropped_column) && strlen($db) && strlen($table) && ! empty($dropped_column)) {
|
||||
if (isset($dropped_column)
|
||||
&& strlen($db)
|
||||
&& strlen($table)
|
||||
&& ! empty($dropped_column)
|
||||
) {
|
||||
include_once 'libraries/relation_cleanup.lib.php';
|
||||
PMA_relationsCleanupColumn($db, $table, $dropped_column);
|
||||
// to refresh the list of indexes (Ajax mode)
|
||||
@ -798,14 +832,16 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
|
||||
$message = PMA_Message::getMessageForDeletedRows($num_rows);
|
||||
} elseif ($is_insert) {
|
||||
if ($is_replace) {
|
||||
/* For replace we get DELETED + INSERTED row count, so we have to call it affected */
|
||||
// For replace we get DELETED + INSERTED row count,
|
||||
// so we have to call it affected
|
||||
$message = PMA_Message::getMessageForAffectedRows($num_rows);
|
||||
} else {
|
||||
$message = PMA_Message::getMessageForInsertedRows($num_rows);
|
||||
}
|
||||
$insert_id = PMA_DBI_insert_id();
|
||||
if ($insert_id != 0) {
|
||||
// insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this
|
||||
// insert_id is id of FIRST record inserted in one insert,
|
||||
// so if we inserted multiple rows, we had to increment this
|
||||
$message->addMessage('[br]');
|
||||
// need to use a temporary because the Message class
|
||||
// currently supports adding parameters only to the first
|
||||
@ -890,10 +926,12 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
|
||||
if (0 == $num_rows && 'sql.php' == $cfg['DefaultTabTable']) {
|
||||
$goto = str_replace('sql.php', 'tbl_structure.php', $goto);
|
||||
}
|
||||
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto) . '&message=' . urlencode($message));
|
||||
PMA_sendHeaderLocation(
|
||||
$cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto) . '&message=' . urlencode($message)
|
||||
);
|
||||
} // end else
|
||||
exit();
|
||||
// end no rows returned
|
||||
// end no rows returned
|
||||
} else {
|
||||
// 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
|
||||
@ -947,7 +985,8 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
|
||||
|
||||
echo getTableHtmlForMultipleQueries(
|
||||
$displayResultsObject, $db, $sql_data, $goto,
|
||||
$pmaThemeImage, $text_dir, $printview, $url_query, $disp_mode, $sql_limit_to_append
|
||||
$pmaThemeImage, $text_dir, $printview, $url_query,
|
||||
$disp_mode, $sql_limit_to_append
|
||||
);
|
||||
|
||||
} else {
|
||||
@ -956,8 +995,9 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
|
||||
|
||||
$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
|
||||
$is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage,
|
||||
$text_dir, $is_maint, $is_explain, $is_show, $showtable,
|
||||
$printview, $url_query
|
||||
);
|
||||
|
||||
echo $displayResultsObject->getTable($result, $disp_mode, $analyzed_sql);
|
||||
@ -1116,13 +1156,14 @@ $(makeProfilingChart);
|
||||
$printview = isset($printview) ? $printview : null;
|
||||
$url_query = isset($url_query) ? $url_query : null;
|
||||
|
||||
if (!empty($sql_data) && ($sql_data['valid_queries'] > 1) || $is_procedure) {
|
||||
if (! empty($sql_data) && ($sql_data['valid_queries'] > 1) || $is_procedure) {
|
||||
|
||||
$_SESSION['is_multi_query'] = true;
|
||||
|
||||
echo getTableHtmlForMultipleQueries(
|
||||
$displayResultsObject, $db, $sql_data, $goto,
|
||||
$pmaThemeImage, $text_dir, $printview, $url_query, $disp_mode, $sql_limit_to_append
|
||||
$pmaThemeImage, $text_dir, $printview, $url_query,
|
||||
$disp_mode, $sql_limit_to_append
|
||||
);
|
||||
|
||||
} else {
|
||||
@ -1131,8 +1172,9 @@ $(makeProfilingChart);
|
||||
|
||||
$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
|
||||
$is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage,
|
||||
$text_dir, $is_maint, $is_explain, $is_show, $showtable,
|
||||
$printview, $url_query
|
||||
);
|
||||
|
||||
echo $displayResultsObject->getTable($result, $disp_mode, $analyzed_sql);
|
||||
@ -1140,7 +1182,11 @@ $(makeProfilingChart);
|
||||
}
|
||||
|
||||
// BEGIN INDEX CHECK See if indexes should be checked.
|
||||
if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
|
||||
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)) {
|
||||
@ -1235,8 +1281,8 @@ function PMA_getDisplayPropertyParams($sql_query, $is_select)
|
||||
$is_group = preg_match('@(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+@i', $sql_query);
|
||||
$is_func = ! $is_group && (preg_match('@[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(@i', $sql_query));
|
||||
$is_count = ! $is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query));
|
||||
$is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query));
|
||||
$is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query));
|
||||
$is_export = preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query);
|
||||
$is_analyse = preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query);
|
||||
} elseif (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) {
|
||||
$is_explain = true;
|
||||
} elseif (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) {
|
||||
@ -1323,9 +1369,9 @@ function PMA_getTableNameBySQL($sql, $tables)
|
||||
* @param PMA_DisplayResults $displayResultsObject object
|
||||
* @param string $db database name
|
||||
* @param array $sql_data information about SQL statement
|
||||
* @param string $goto the URL to go back in case of errors
|
||||
* @param string $goto URL to go back in case of errors
|
||||
* @param string $pmaThemeImage path for theme images directory
|
||||
* @param string $text_dir
|
||||
* @param string $text_dir text direction
|
||||
* @param string $printview
|
||||
* @param string $url_query URL query
|
||||
* @param array $disp_mode the display mode
|
||||
@ -1358,7 +1404,9 @@ function getTableHtmlForMultipleQueries(
|
||||
$is_affected = false;
|
||||
|
||||
$result = PMA_DBI_store_result();
|
||||
$fields_meta = ($result !== false) ? PMA_DBI_get_fields_meta($result) : array();
|
||||
$fields_meta = ($result !== false)
|
||||
? PMA_DBI_get_fields_meta($result)
|
||||
: array();
|
||||
$fields_cnt = count($fields_meta);
|
||||
|
||||
// Initialize needed params related to each query in multiquery statement
|
||||
@ -1366,14 +1414,22 @@ function getTableHtmlForMultipleQueries(
|
||||
|
||||
// 'Use' query can change the database
|
||||
if (stripos($sql_data['valid_sql'][$sql_no], "use ")) {
|
||||
$db = PMA_getNewDatabase($sql_data['valid_sql'][$sql_no], $databases_array);
|
||||
$db = PMA_getNewDatabase(
|
||||
$sql_data['valid_sql'][$sql_no],
|
||||
$databases_array
|
||||
);
|
||||
}
|
||||
$parsed_sql = PMA_SQP_parse($sql_data['valid_sql'][$sql_no]);
|
||||
$table = PMA_getTableNameBySQL($sql_data['valid_sql'][$sql_no], $tables_array);
|
||||
$table = PMA_getTableNameBySQL(
|
||||
$sql_data['valid_sql'][$sql_no],
|
||||
$tables_array
|
||||
);
|
||||
|
||||
$analyzed_sql = PMA_SQP_analyze($parsed_sql);
|
||||
$is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
|
||||
$unlim_num_rows = PMA_Table::countRecords($db, $table, $force_exact = true);
|
||||
$unlim_num_rows = PMA_Table::countRecords(
|
||||
$db, $table, $force_exact = true
|
||||
);
|
||||
$showtable = PMA_Table::sGetStatusInfo($db, $table, null, true);
|
||||
$url_query = PMA_generate_common_url($db, $table);
|
||||
|
||||
@ -1392,7 +1448,12 @@ function getTableHtmlForMultipleQueries(
|
||||
&& isset($analyzed_sql[0]['queryflags']['select_from'])
|
||||
&& count($analyzed_sql[0]['table_ref']) == 1
|
||||
) {
|
||||
PMA_handleSortOrder($db, $table, $analyzed_sql, $sql_data['valid_sql'][$sql_no]);
|
||||
PMA_handleSortOrder(
|
||||
$db,
|
||||
$table,
|
||||
$analyzed_sql,
|
||||
$sql_data['valid_sql'][$sql_no]
|
||||
);
|
||||
}
|
||||
|
||||
// Do append a "LIMIT" clause?
|
||||
@ -1403,7 +1464,9 @@ function getTableHtmlForMultipleQueries(
|
||||
&& empty($analyzed_sql[0]['limit_clause'])
|
||||
) {
|
||||
$sql_data['valid_sql'][$sql_no] = PMA_getSqlWithLimitClause(
|
||||
$sql_data['valid_sql'][$sql_no], $analyzed_sql, $sql_limit_to_append
|
||||
$sql_data['valid_sql'][$sql_no],
|
||||
$analyzed_sql,
|
||||
$sql_limit_to_append
|
||||
);
|
||||
}
|
||||
|
||||
@ -1422,11 +1485,15 @@ function getTableHtmlForMultipleQueries(
|
||||
|
||||
if (isset($sql_data['valid_sql'][$sql_no])) {
|
||||
|
||||
$displayResultsObject->__set('_sql_query', $sql_data['valid_sql'][$sql_no]);
|
||||
$displayResultsObject->__set(
|
||||
'_sql_query',
|
||||
$sql_data['valid_sql'][$sql_no]
|
||||
);
|
||||
$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
|
||||
$is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage,
|
||||
$text_dir, $is_maint, $is_explain, $is_show, $showtable,
|
||||
$printview, $url_query
|
||||
);
|
||||
|
||||
}
|
||||
@ -1458,10 +1525,12 @@ function getTableHtmlForMultipleQueries(
|
||||
/**
|
||||
* Handle remembered sorting order, only for single table query
|
||||
*
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param array $analyzed_sql the analyzed query
|
||||
* @param string $full_sql_query SQL query
|
||||
* @param string $db database name
|
||||
* @param string $table table name
|
||||
* @param array &$analyzed_sql the analyzed query
|
||||
* @param string &$full_sql_query SQL query
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_handleSortOrder($db, $table, &$analyzed_sql, &$full_sql_query)
|
||||
{
|
||||
@ -1472,8 +1541,9 @@ function PMA_handleSortOrder($db, $table, &$analyzed_sql, &$full_sql_query)
|
||||
if ($sorted_col) {
|
||||
// retrieve the remembered sorting order for current table
|
||||
$sql_order_to_append = ' ORDER BY ' . $sorted_col . ' ';
|
||||
$full_sql_query = $analyzed_sql[0]['section_before_limit'] . $sql_order_to_append
|
||||
. $analyzed_sql[0]['limit_clause'] . ' ' . $analyzed_sql[0]['section_after_limit'];
|
||||
$full_sql_query = $analyzed_sql[0]['section_before_limit']
|
||||
. $sql_order_to_append . $analyzed_sql[0]['limit_clause']
|
||||
. ' ' . $analyzed_sql[0]['section_after_limit'];
|
||||
|
||||
// update the $analyzed_sql
|
||||
$analyzed_sql[0]['section_before_limit'] .= $sql_order_to_append;
|
||||
@ -1481,7 +1551,10 @@ function PMA_handleSortOrder($db, $table, &$analyzed_sql, &$full_sql_query)
|
||||
}
|
||||
} else {
|
||||
// store the remembered table into session
|
||||
$pmatable->setUiProp(PMA_Table::PROP_SORTED_COLUMN, $analyzed_sql[0]['order_by_clause']);
|
||||
$pmatable->setUiProp(
|
||||
PMA_Table::PROP_SORTED_COLUMN,
|
||||
$analyzed_sql[0]['order_by_clause']
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1495,8 +1568,9 @@ function PMA_handleSortOrder($db, $table, &$analyzed_sql, &$full_sql_query)
|
||||
*
|
||||
* @return string limit clause appended SQL query
|
||||
*/
|
||||
function PMA_getSqlWithLimitClause($full_sql_query, $analyzed_sql, $sql_limit_to_append)
|
||||
{
|
||||
function PMA_getSqlWithLimitClause($full_sql_query, $analyzed_sql,
|
||||
$sql_limit_to_append
|
||||
) {
|
||||
return $analyzed_sql[0]['section_before_limit'] . "\n"
|
||||
. $sql_limit_to_append . $analyzed_sql[0]['section_after_limit'];
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user