📄 db_details_qbe.php
字号:
<?php/* $Id: db_details_qbe.php 9170 2006-07-07 14:30:00Z lem9 $ */// vim: expandtab sw=4 ts=4 sts=4:/** * query by example the whole database *//** * requirements */require_once './libraries/common.lib.php';require_once './libraries/Table.class.php';require_once './libraries/relation.lib.php';/** * Gets the relation settings */$cfgRelation = PMA_getRelationsParam();/** * A query has been submitted -> execute it, else display the headers */if (isset($_REQUEST['submit_sql']) && preg_match('@^SELECT@i', $_REQUEST['encoded_sql_query'])) { $goto = 'db_details.php'; $zero_rows = htmlspecialchars($GLOBALS['strSuccess']); $sql_query = urldecode($_REQUEST['encoded_sql_query']); require './sql.php'; exit;} else { $sub_part = '_qbe'; require './libraries/db_details_common.inc.php'; $url_query .= '&goto=db_details_qbe.php'; $url_params['goto'] = 'db_details_qbe.php'; require './libraries/db_details_db_info.inc.php';}if (isset($_REQUEST['submit_sql']) && ! preg_match('@^SELECT@i', $_REQUEST['encoded_sql_query'])) { echo '<div class="warning">' . $GLOBALS['strHaveToShow'] . '</div>';}/** * Initialize some variables */$col_cnt = isset($_REQUEST['col_cnt']) ? (int) $_REQUEST['col_cnt'] : 3;$add_col = isset($_REQUEST['add_col']) ? (int) $_REQUEST['add_col'] : 0;$add_row = isset($_REQUEST['add_row']) ? (int) $_REQUEST['add_row'] : 0;$rows = isset($_REQUEST['rows']) ? (int) $_REQUEST['rows'] : 0;$ins_col = isset($_REQUEST['ins_col']) ? $_REQUEST['ins_col'] : array();$del_col = isset($_REQUEST['del_col']) ? $_REQUEST['del_col'] : array();$prev_criteria = isset($_REQUEST['prev_criteria']) ? $_REQUEST['prev_criteria'] : array();$criteria = isset($_REQUEST['criteria']) ? $_REQUEST['criteria'] : array_fill(0, $col_cnt, '');$ins_row = isset($_REQUEST['ins_row']) ? $_REQUEST['ins_row'] : array_fill(0, $col_cnt, '');$del_row = isset($_REQUEST['del_row']) ? $_REQUEST['del_row'] : array_fill(0, $col_cnt, '');$and_or_row = isset($_REQUEST['and_or_row']) ? $_REQUEST['and_or_row'] : array_fill(0, $col_cnt, '');$and_or_col = isset($_REQUEST['and_or_col']) ? $_REQUEST['and_or_col'] : array_fill(0, $col_cnt, '');// minimum width$form_column_width = 12;$col = max($col_cnt + $add_col, 0);$row = max($rows + $add_row, 0);// The tables list sent by a previously submitted formif (!empty($TableList)) { $cnt_table_list = count($TableList); for ($x = 0; $x < $cnt_table_list; $x++) { $tbl_names[urldecode($TableList[$x])] = ' selected="selected"'; }} // end if// this was a work in progress, deactivated for now//$columns = PMA_DBI_get_columns_full($GLOBALS['db']);//$tables = PMA_DBI_get_columns_full($GLOBALS['db']);/** * Prepares the form */$tbl_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);$tbl_result_cnt = PMA_DBI_num_rows($tbl_result);$i = 0;$k = 0;// The tables list gets from MySQLwhile ($i < $tbl_result_cnt) { list($tbl) = PMA_DBI_fetch_row($tbl_result); $fld_results = PMA_DBI_get_fields($db, $tbl); $fld_results_cnt = ($fld_results) ? count($fld_results) : 0; $j = 0; if (empty($tbl_names[$tbl]) && !empty($TableList)) { $tbl_names[$tbl] = ''; } else { $tbl_names[$tbl] = ' selected="selected"'; } // end if // The fields list per selected tables if ($tbl_names[$tbl] == ' selected="selected"') { $fld[$k++] = PMA_backquote($tbl) . '.*'; while ($j < $fld_results_cnt) { $fld[$k] = PMA_convert_display_charset($fld_results[$j]['Field']); $fld[$k] = PMA_backquote($tbl) . '.' . PMA_backquote($fld[$k]); // increase the width if necessary if (strlen($fld[$k]) > $form_column_width) { $form_column_width = strlen($fld[$k]); } //end if $k++; $j++; } // end while } // end if $i++;} // end ifPMA_DBI_free_result($tbl_result);// largest width found$realwidth = $form_column_width . 'ex';/** * Displays the Query by example form */function showColumnSelectCell($columns, $column_number, $selected = ''){ ?> <td align="center"> <select name="Field[<?php echo $column_number; ?>]" size="1"> <option value=""></option> <?php foreach ($columns as $column) { if ($column === $selected) { $sel = ' selected="selected"'; } else { $sel = ''; } echo ' '; echo '<option value="' . htmlspecialchars($column) . '"' . $sel . '>' . htmlspecialchars($column) . '</option>' . "\n"; } ?> </select> </td> <?php}?><form action="db_details_qbe.php" method="post"><table class="data" style="width: 100%;"><tr class="odd noclick"> <th><?php echo $strField; ?>:</th><?php$z = 0;for ($x = 0; $x < $col; $x++) { if (isset($ins_col[$x]) && $ins_col[$x] == 'on') { showColumnSelectCell( $fld, $z ); $z++; } if (! empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') { continue; } $selected = ''; if (isset($Field[$x])) { $selected = urldecode($Field[$x]); $curField[$z] = urldecode($Field[$x]); } showColumnSelectCell($fld, $z, $selected); $z++;} // end for?></tr><!-- Sort row --><tr class="even noclick"> <th><?php echo $strSort; ?>:</th><?php$z = 0;for ($x = 0; $x < $col; $x++) { if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') { ?> <td align="center"> <select style="width: <?php echo $realwidth; ?>" name="Sort[<?php echo $z; ?>]" size="1"> <option value=""></option> <option value="ASC"><?php echo $strAscending; ?></option> <option value="DESC"><?php echo $strDescending; ?></option> </select> </td> <?php $z++; } // end if echo "\n"; if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') { continue; } ?> <td align="center"> <select style="width: <?php echo $realwidth; ?>" name="Sort[<?php echo $z; ?>]" size="1"> <option value=""></option> <?php echo "\n"; // If they have chosen all fields using the * selector, // then sorting is not available // Robbat2 - Fix for Bug #570698 if (isset($Sort[$x]) && isset($Field[$x]) && substr(urldecode($Field[$x]), -2) == '.*') { $Sort[$x] = ''; } //end if if (isset($Sort[$x]) && $Sort[$x] == 'ASC') { $curSort[$z] = $Sort[$x]; $sel = ' selected="selected"'; } else { $sel = ''; } // end if echo ' '; echo '<option value="ASC"' . $sel . '>' . $strAscending . '</option>' . "\n"; if (isset($Sort[$x]) && $Sort[$x] == 'DESC') { $curSort[$z] = $Sort[$x]; $sel = ' selected="selected"'; } else { $sel = ''; } // end if echo ' '; echo '<option value="DESC"' . $sel . '>' . $strDescending . '</option>' . "\n"; ?> </select> </td> <?php $z++; echo "\n";} // end for?></tr><!-- Show row --><tr class="odd noclick"> <th><?php echo $strShow; ?>:</th><?php$z = 0;for ($x = 0; $x < $col; $x++) { if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') { ?> <td align="center"> <input type="checkbox" name="Show[<?php echo $z; ?>]" /> </td> <?php $z++; } // end if echo "\n"; if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') { continue; } if (isset($Show[$x])) { $checked = ' checked="checked"'; $curShow[$z] = $Show[$x]; } else { $checked = ''; } ?> <td align="center"> <input type="checkbox" name="Show[<?php echo $z; ?>]"<?php echo $checked; ?> /> </td> <?php $z++; echo "\n";} // end for?></tr><!-- Criteria row --><tr class="even noclick"> <th><?php echo $strCriteria; ?>:</th><?php$z = 0;for ($x = 0; $x < $col; $x++) { if (!empty($ins_col) && isset($ins_col[$x]) && $ins_col[$x] == 'on') { ?> <td align="center"> <input type="text" name="criteria[<?php echo $z; ?>]" value="" class="textfield" style="width: <?php echo $realwidth; ?>" size="20" /> </td> <?php $z++; } // end if echo "\n"; if (!empty($del_col) && isset($del_col[$x]) && $del_col[$x] == 'on') { continue; } if (isset($criteria[$x])) { $stripped_Criteria = $criteria[$x]; } if ((empty($prev_criteria) || !isset($prev_criteria[$x])) || urldecode($prev_criteria[$x]) != htmlspecialchars($stripped_Criteria)) { $curCriteria[$z] = $stripped_Criteria; $encoded_Criteria = urlencode($stripped_Criteria); } else { $curCriteria[$z] = urldecode($prev_criteria[$x]); $encoded_Criteria = $prev_criteria[$x]; } ?> <td align="center"> <input type="hidden" name="prev_criteria[<?php echo $z; ?>]" value="<?php echo $encoded_Criteria; ?>" /> <input type="text" name="criteria[<?php echo $z; ?>]" value="<?php echo htmlspecialchars($stripped_Criteria); ?>" class="textfield" style="width: <?php echo $realwidth; ?>" size="20" /> </td> <?php $z++; echo "\n";} // end for?></tr><!-- And/Or columns and rows --><?php$w = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -