📄 sql_query_form.lib.php
字号:
<?php/* $Id: sql_query_form.lib.php,v 1.23 2005/11/16 18:54:53 lem9 Exp $ */// vim: expandtab sw=4 ts=4 sts=4:/** * functions for displaying the sql query form * * @usedby server_sql.php * @usedby db_details.php * @usedby tbl_properties.php * @usedby tbl_properties_structure.php * @usedby querywindow.php */require_once('./libraries/file_listing.php'); // used for file listing/** * prints the sql query boxes * * @usedby server_sql.php * @usedby db_details.php * @usedby tbl_properties.php * @usedby tbl_properties_structure.php * @usedby querywindow.php * @uses $GLOBALS['table'] * @uses $GLOBALS['db'] * @uses $GLOBALS['server'] * @uses $GLOBALS['goto'] * @uses $GLOBALS['is_upload'] from common.lib.php * @uses $GLOBALS['sql_query'] from grab_globals.lib.php * @uses $GLOBALS['cfg']['DefaultQueryTable'] * @uses $GLOBALS['cfg']['DefaultQueryDatabase'] * @uses $GLOBALS['cfg']['Servers'] * @uses $GLOBALS['cfg']['DefaultTabDatabase'] * @uses $GLOBALS['cfg']['DefaultQueryDatabase'] * @uses $GLOBALS['cfg']['DefaultQueryTable'] * @uses $GLOBALS['cfg']['Bookmark']['db'] * @uses $GLOBALS['cfg']['Bookmark']['table'] * @uses $GLOBALS['strSuccess'] * @uses PMA_generate_common_url() * @uses PMA_backquote() * @uses PMA_DBI_fetch_result() * @uses PMA_showMySQLDocu() * @uses PMA_generate_common_hidden_inputs() * @uses PMA_sqlQueryFormBookmark() * @uses PMA_sqlQueryFormInsert() * @uses PMA_sqlQueryFormUpload() * @uses PMA_DBI_QUERY_STORE * @uses PMA_set_enc_form() * @uses sprintf() * @uses htmlspecialchars() * @uses str_replace() * @uses md5() * @uses function_exists() * @param boolean|string $query query to display in the textarea * or true to display last executed * @param boolean|string $display_tab sql|files|history|full|FALSE * what part to display * false if not inside querywindow */function PMA_sqlQueryForm( $query = true, $display_tab = false ) { // check tab to display if inside querywindow if ( ! $display_tab ) { $display_tab = 'full'; $is_querywindow = false; } else { $is_querywindow = true; } // query to show if ( true === $query ) { $query = empty( $GLOBALS['sql_query'] ) ? '' : $GLOBALS['sql_query']; } // set enctype to multipart for file uploads if ( $GLOBALS['is_upload'] ) { $enctype = ' enctype="multipart/form-data"'; } else { $enctype = ''; } $table = ''; $db = ''; if ( empty( $GLOBALS['db'] ) ) { // prepare for server related $goto = empty( $GLOBALS['goto'] ) ? 'server_sql.php' : $GLOBALS['goto']; } elseif ( empty( $GLOBALS['table'] ) ) { // prepare for db related $db = $GLOBALS['db']; $goto = empty( $GLOBALS['goto'] ) ? 'db_details.php' : $GLOBALS['goto']; } else { $table = $GLOBALS['table']; $db = $GLOBALS['db']; $goto = empty( $GLOBALS['goto'] ) ? 'tbl_properties.php' : $GLOBALS['goto']; } // start output if ( $is_querywindow ) { ?> <form method="post" id="sqlqueryform" target="phpmain<?php echo md5( $GLOBALS['cfg']['PmaAbsoluteUri'] ); ?>" action="import.php"<?php echo $enctype; ?> name="sqlform" onsubmit="this.target=window.opener.frames[1].name; return checkSqlQuery( this );" > <?php } else { echo '<form method="post" action="import.php" ' . $enctype . ' id="sqlqueryform"' .' onsubmit="return checkSqlQuery(this)" name="sqlform">' . "\n"; } if ( $is_querywindow ) { echo '<input type="hidden" name="focus_querywindow" value="true" />' ."\n"; if ( $display_tab != 'sql' && $display_tab != 'full' ) { echo '<input type="hidden" name="sql_query" value="" />' . "\n"; echo '<input type="hidden" name="show_query" value="1" />' . "\n"; } } echo '<input type="hidden" name="is_js_confirmed" value="0" />' . "\n" .PMA_generate_common_hidden_inputs( $db, $table ) . "\n" .'<input type="hidden" name="pos" value="0" />' . "\n" .'<input type="hidden" name="goto" value="' .htmlspecialchars( $goto ) . '" />' . "\n" .'<input type="hidden" name="zero_rows" value="' . htmlspecialchars( $GLOBALS['strSuccess'] ) . '" />' . "\n" .'<input type="hidden" name="prev_sql_query" value="' . htmlspecialchars( $query ) . '" />' . "\n"; // display querybox if ( $display_tab === 'full' || $display_tab === 'sql' ) { PMA_sqlQueryFormInsert( $query, $is_querywindow ); } // display uploads if ( $display_tab === 'files' && $GLOBALS['is_upload'] ) { PMA_sqlQueryFormUpload(); } // Bookmark Support if ( $display_tab === 'full' || $display_tab === 'history' ) { if ( ! empty( $GLOBALS['cfg']['Bookmark'] ) && $GLOBALS['cfg']['Bookmark']['db'] && $GLOBALS['cfg']['Bookmark']['table'] ) { PMA_sqlQueryFormBookmark(); } } // Encoding setting form appended by Y.Kawada if ( function_exists('PMA_set_enc_form') ) { echo PMA_set_enc_form(' '); } echo '</form>' . "\n";}/** * prints querybox fieldset * * @usedby PMA_sqlQueryForm() * @uses $GLOBALS['text_dir'] * @uses $GLOBALS['cfg']['TextareaAutoSelect'] * @uses $GLOBALS['cfg']['TextareaCols'] * @uses $GLOBALS['cfg']['TextareaRows'] * @uses $GLOBALS['strShowThisQuery'] * @uses $GLOBALS['strGo'] * @uses PMA_availableDatabases() * @uses PMA_USR_OS * @uses PMA_USR_BROWSER_AGENT * @uses PMA_USR_BROWSER_VER * @uses PMA_availableDatabases() * @uses htmlspecialchars() * @param string $query query to display in the textarea * @param boolean $is_querywindow if inside querywindow or not */function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) { // enable auto select text in textarea if ( $GLOBALS['cfg']['TextareaAutoSelect'] ) { $auto_sel = ' onfocus="selectContent( this, sql_box_locked, true )"'; } else { $auto_sel = ''; } // enable locking if inside query window if ( $is_querywindow ) { $locking = ' onkeypress="document.sqlform.elements[\'LockFromUpdate\'].' .'checked = true;"'; } else { $locking = ''; } $table = ''; $db = ''; $fields_list = array(); if ( empty( $GLOBALS['db'] ) ) { // prepare for server related $legend = sprintf( $GLOBALS['strRunSQLQueryOnServer'], htmlspecialchars( $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host'] ) ); } elseif ( empty( $GLOBALS['table'] ) ) { // prepare for db related $db = $GLOBALS['db']; // if you want navigation: $strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url( $db ) . '"'; if ( $is_querywindow ) { $strDBLink .= ' target="_self"' . ' onclick="this.target=window.opener.frames[1].name"'; } $strDBLink .= '>' . htmlspecialchars( $db ) . '</a>'; // else use // $strDBLink = htmlspecialchars( $db ); $legend = sprintf( $GLOBALS['strRunSQLQuery'], $strDBLink ); if ( empty( $query ) ) { $query = str_replace( '%d', PMA_backquote( $db ), $GLOBALS['cfg']['DefaultQueryDatabase'] ); } } else { $table = $GLOBALS['table']; $db = $GLOBALS['db']; // Get the list and number of fields // we do a try_query here, because we could be in the query window, // trying to synchonize and the table has not yet been created $fields_list = PMA_DBI_fetch_result( 'SHOW FULL COLUMNS FROM ' . PMA_backquote( $db ) . '.' . PMA_backquote( $GLOBALS['table'] )); $strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url( $db ) . '"'; if ( $is_querywindow ) { $strDBLink .= ' target="_self"' . ' onclick="this.target=window.opener.frames[1].name"'; } $strDBLink .= '>' . htmlspecialchars( $db ) . '</a>'; // else use // $strDBLink = htmlspecialchars( $db ); $legend = sprintf( $GLOBALS['strRunSQLQuery'], $strDBLink ); if ( empty( $query ) && count( $fields_list ) ) { $field_names = array(); foreach ( $fields_list as $field ) { $field_names[] = PMA_backquote($field['Field']); } $query = str_replace( '%d', PMA_backquote( $db ), str_replace( '%t', PMA_backquote( $table ), str_replace( '%f', implode( ', ', $field_names ), $GLOBALS['cfg']['DefaultQueryTable'] ) ) ); unset($field_names); } } $legend .= ': ' . PMA_showMySQLDocu( 'SQL-Syntax', 'SELECT' ); if ( count( $fields_list ) ) { $sqlquerycontainer_id = 'sqlquerycontainer'; } else { $sqlquerycontainer_id = 'sqlquerycontainerfull'; } echo '<a name="querybox"></a>' . "\n" .'<div id="queryboxcontainer">' . "\n" .'<fieldset id="querybox">' . "\n"; echo '<legend>' . $legend . '</legend>' . "\n"; echo '<div id="queryfieldscontainer">' . "\n";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -