📄 sql.php
字号:
// // another case where the count_query is wrong: // SELECT COUNT(*), f1 from t1 group by f1 // and you click to sort on count(*) // } $cnt_all_result = PMA_DBI_query('SELECT FOUND_ROWS() as count;'); list($unlim_num_rows) = PMA_DBI_fetch_row($cnt_all_result); @PMA_DBI_free_result($cnt_all_result); } } // end else "just browsing" } else { // not $is_select $unlim_num_rows = 0; } // end rows total count // garvin: if a table or database gets dropped, check column comments. if (isset($purge) && $purge == '1') { require_once './libraries/relation_cleanup.lib.php'; if (isset($table) && isset($db) && strlen($table) && strlen($db)) { PMA_relationsCleanupTable($db, $table); } elseif (isset($db) && strlen($db)) { PMA_relationsCleanupDatabase($db); } else { // garvin: VOID. No DB/Table gets deleted. } // end if relation-stuff } // end if ($purge) // garvin: If a column gets dropped, do relation magic. if (isset($cpurge) && $cpurge == '1' && isset($purgekey) && isset($db) && isset($table) && strlen($db) && strlen($table) && !empty($purgekey)) { require_once './libraries/relation_cleanup.lib.php'; PMA_relationsCleanupColumn($db, $table, $purgekey); } // end if column PMA_* purge} // end else "didn't ask to see php code"// No rows returned -> move back to the calling pageif ($num_rows < 1 || $is_affected) { if ($is_delete) { $message = $strDeletedRows . ' ' . $num_rows; } elseif ($is_insert) { if ($is_replace) { /* For replace we get DELETED + INSERTED row count, so we have to call it affected */ $message = $strAffectedRows . ' ' . $num_rows; } else { $message = $strInsertedRows . ' ' . $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 $message .= '[br]'.$strInsertedRowId . ' ' . ($insert_id + $num_rows - 1); } } elseif ($is_affected) { $message = $strAffectedRows . ' ' . $num_rows; // Ok, here is an explanation for the !$is_select. // The form generated by sql_query_form.lib.php // and db_sql.php has many submit buttons // on the same form, and some confusion arises from the // fact that $zero_rows is sent for every case. // The $zero_rows containing $strSuccess and sent with // the form should not have priority over // errors like $strEmptyResultSet } elseif (!empty($zero_rows) && !$is_select) { $message = $zero_rows; } elseif (!empty($GLOBALS['show_as_php'])) { $message = $strShowingPhp; } elseif (isset($GLOBALS['show_as_php'])) { /* User disable showing as PHP, query is only displayed */ $message = $strShowingSQL; } elseif (!empty($GLOBALS['validatequery'])) { $message = $strValidateSQL; } else { $message = $strEmptyResultSet; } $message .= ' ' . (isset($GLOBALS['querytime']) ? '(' . sprintf($strQueryTime, $GLOBALS['querytime']) . ')' : ''); if ($is_gotofile) { $goto = PMA_securePath($goto); // Checks for a valid target script $is_db = $is_table = false; include 'libraries/db_table_exists.lib.php'; if (strpos($goto, 'tbl_') === 0 && ! $is_table) { if (isset($table)) { unset($table); } $goto = 'db_sql.php'; } if (strpos($goto, 'db_') === 0 && ! $is_db) { if (isset($db)) { unset($db); } $goto = 'main.php'; } // Loads to target script if (strpos($goto, 'db_') === 0 || strpos($goto, 'tbl_') === 0) { $js_to_run = 'functions.js'; } if ($goto != 'main.php') { require_once './libraries/header.inc.php'; } $active_page = $goto; require './' . $goto; } else { PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto) . '&message=' . urlencode($message)); } // end else exit();} // end no rows returned// At least one row is returned -> displays a table with resultselse { // Displays the headers if (isset($show_query)) { unset($show_query); } if (isset($printview) && $printview == '1') { require_once './libraries/header_printview.inc.php'; } else { $js_to_run = 'functions.js'; unset($message); if (isset($table) && strlen($table)) { require './libraries/tbl_common.php'; $url_query .= '&goto=tbl_sql.php&back=tbl_sql.php'; require './libraries/tbl_info.inc.php'; require './libraries/tbl_links.inc.php'; } elseif (isset($db) && strlen($db)) { require './libraries/db_common.inc.php'; require './libraries/db_info.inc.php'; } else { require './libraries/server_common.inc.php'; require './libraries/server_links.inc.php'; } } if (isset($db) && strlen($db)) { require_once './libraries/relation.lib.php'; $cfgRelation = PMA_getRelationsParam(); } // Gets the list of fields properties if (isset($result) && $result) { $fields_meta = PMA_DBI_get_fields_meta($result); $fields_cnt = count($fields_meta); } // Display previous update query (from tbl_replace) if (isset($disp_query) && $cfg['ShowSQL'] == true) { $tmp_sql_query = $GLOBALS['sql_query']; $GLOBALS['sql_query'] = $disp_query; PMA_showMessage($disp_message); $GLOBALS['sql_query'] = $tmp_sql_query; } // Displays the results in a table require_once './libraries/display_tbl.lib.php'; if (empty($disp_mode)) { // see the "PMA_setDisplayMode()" function in // libraries/display_tbl.lib.php $disp_mode = 'urdr111101'; } if (!isset($dontlimitchars)) { $dontlimitchars = 0; } // hide edit and delete links for information_schema if (PMA_MYSQL_INT_VERSION >= 50002 && isset($db) && $db == 'information_schema') { $disp_mode = 'nnnn110111'; } PMA_displayTable($result, $disp_mode, $analyzed_sql); PMA_DBI_free_result($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) { $indexes = $indexes_info = $indexes_data = array(); $tbl_ret_keys = PMA_get_indexes(urldecode($tbl_name), $err_url_0); PMA_extract_indexes($tbl_ret_keys, $indexes, $indexes_info, $indexes_data); $idx_collection = PMA_show_indexes(urldecode($tbl_name), $indexes, $indexes_info, $indexes_data, false); $check = PMA_check_indexes($idx_collection); if (!empty($check)) { ?><table border="0" cellpadding="2" cellspacing="0"> <tr> <td class="tblHeaders" colspan="7"><?php printf($strIndexWarningTable, urldecode($tbl_name)); ?></td> </tr> <?php echo $check; ?></table> <?php } } } // End INDEX CHECK // Bookmark support if required if ($disp_mode[7] == '1' && (isset($cfg['Bookmark']) && ! empty($cfg['Bookmark']['db']) && ! empty($cfg['Bookmark']['table']) && empty($id_bookmark)) && !empty($sql_query)) { echo "\n"; $goto = 'sql.php?' . PMA_generate_common_url($db, $table) . '&pos=' . $pos . '&session_max_rows=' . $session_max_rows . '&disp_direction=' . $disp_direction . '&repeat_cells=' . $repeat_cells . '&dontlimitchars=' . $dontlimitchars . '&sql_query=' . urlencode($sql_query) . '&id_bookmark=1'; ?><form action="sql.php" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');"><?php echo PMA_generate_common_hidden_inputs(); ?><input type="hidden" name="goto" value="<?php echo $goto; ?>" /><input type="hidden" name="fields[dbase]" value="<?php echo htmlspecialchars($db); ?>" /><input type="hidden" name="fields[user]" value="<?php echo $cfg['Bookmark']['user']; ?>" /><input type="hidden" name="fields[query]" value="<?php echo urlencode(isset($complete_query) ? $complete_query : $sql_query); ?>" /><fieldset> <legend><?php echo ($cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_bookmark.png" width="16" height="16" alt="' . $strBookmarkThis . '" />' : '') . $strBookmarkThis;?> </legend> <div class="formelement"> <label for="fields_label_"><?php echo $strBookmarkLabel; ?>:</label> <input type="text" id="fields_label_" name="fields[label]" value="" /> </div> <div class="formelement"> <input type="checkbox" name="bkm_all_users" id="bkm_all_users" value="true" /> <label for="bkm_all_users"><?php echo $strBookmarkAllUsers; ?></label> </div> <div class="clearfloat"></div></fieldset><fieldset class="tblFooters"> <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" /></fieldset></form> <?php } // end bookmark support // Do print the page if required if (isset($printview) && $printview == '1') { ?><script type="text/javascript" language="javascript">//<![CDATA[// Do print the pagewindow.onload = function(){ if (typeof(window.print) != 'undefined') { window.print(); }}//]]></script> <?php } // end print case} // end rows returned/** * Displays the footer */require_once './libraries/footer.inc.php';?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -