本文整理汇总了PHP中PMA_get_indexes函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_get_indexes函数的具体用法?PHP PMA_get_indexes怎么用?PHP PMA_get_indexes使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_get_indexes函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_check_indexes
/**
* Function to check over array of indexes and look for common problems
*
* @uses $GLOBALS['strIndexesSeemEqual']
* @uses PMA_get_indexes()
* @uses is_string()
* @uses is_array()
* @uses count()
* @uses array_pop()
* @uses reset()
* @uses current()
* @access public
* @param mixed array of indexes from PMA_get_indexes()
* or name of table
* @return string Output HTML
*/
function PMA_check_indexes($idx_collection)
{
if (is_string($idx_collection)) {
$idx_collection = PMA_get_indexes($idx_collection);
}
// count($idx_collection) < 2:
// there is no need to check if there less than two indexes
if (!is_array($idx_collection) || count($idx_collection) < 2) {
return false;
}
$indexes = array();
foreach ($idx_collection as $index_field) {
$indexes[$index_field['Key_name']][$index_field['Column_name']] = $index_field;
}
$output = '';
// remove last index from stack and ...
while ($while_index = array_pop($indexes)) {
// ... compare with every remaining index in stack
foreach ($indexes as $each_index_name => $each_index) {
if (count($while_index) !== count($each_index)) {
// number of fields are not equal
continue;
}
// compare some key elements of every column in this two indexes
foreach ($each_index as $col_name => $each_index_column) {
if (!isset($while_index[$col_name]) || $while_index[$col_name]['Seq_in_index'] !== $each_index_column['Seq_in_index'] || $while_index[$col_name]['Collation'] !== $each_index_column['Collation'] || $while_index[$col_name]['Sub_part'] !== $each_index_column['Sub_part'] || $while_index[$col_name]['Index_type'] !== $each_index_column['Index_type']) {
continue 2;
}
}
// did not find any difference
// so it makes no sense to have this two equal indexes
// use first column from index to fetch index name
reset($while_index);
$first_column = current($while_index);
$output .= '<div class="warning">';
$output .= $GLOBALS['strIndexesSeemEqual'] . ' ';
$output .= $each_index_name . ', ' . $first_column['Key_name'];
$output .= '</div>';
// there is no need to check any further indexes if we have already
// found that this one has a duplicate
continue 2;
}
}
if ($output) {
$output = '<tr><td colspan=7">' . $output . '</td></tr>';
}
return $output;
}
示例2: PMA_displayTableHeaders
/**
* Displays the headers of the results table
*
* @param array which elements to display
* @param array the list of fields properties
* @param integer the total number of fields returned by the sql query
* @param array the analyzed query
*
* @return boolean always true
*
* @global string $db the database name
* @global string $table the table name
* @global string $goto the url to go back in case of errors
* @global boolean $dontlimitchars whether to limit the number of displayed
* characters of text type fields or not
* @global string $sql_query the sql query
* @global integer $num_rows the total number of rows returned by the
* sql query
* @global integer $pos the current position in results
* @global integer $session_max_rows the maximum number of rows per page
* @global array $vertical_display informations used with vertical display
* mode
* @global string $disp_direction the display mode
* (horizontal/vertical/horizontalflipped)
* @global integer $repeat_cellsthe number of row to display between two
* table headers
*
* @access private
*
* @see PMA_displayTable()
*/
function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '')
{
global $db, $table, $goto, $dontlimitchars;
global $sql_query, $num_rows, $pos, $session_max_rows;
global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
if ($analyzed_sql == '') {
$analyzed_sql = array();
}
// can the result be sorted?
if ($is_display['sort_lnk'] == '1') {
// Just as fallback
$unsorted_sql_query = $sql_query;
if (isset($analyzed_sql[0]['unsorted_query'])) {
$unsorted_sql_query = $analyzed_sql[0]['unsorted_query'];
}
// we need $sort_expression and $sort_expression_nodir
// even if there are many table references
$sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']));
// Get rid of ASC|DESC (TODO: analyzer)
preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches);
$sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
// sorting by indexes, only if it makes sense (only one table ref)
if (isset($analyzed_sql) && isset($analyzed_sql[0]) && isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' && isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) {
// grab indexes data:
PMA_DBI_select_db($db);
if (!defined('PMA_IDX_INCLUDED')) {
$ret_keys = PMA_get_indexes($table);
}
$prev_index = '';
foreach ($ret_keys as $row) {
if ($row['Key_name'] != $prev_index) {
$indexes[] = $row['Key_name'];
$prev_index = $row['Key_name'];
}
$indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
$indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
if (isset($row['Cardinality'])) {
$indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
}
// I don't know what does the following column mean....
// $indexes_info[$row['Key_name']]['Packed'] = $row['Packed'];
$indexes_info[$row['Key_name']]['Comment'] = isset($row['Comment']) ? $row['Comment'] : '';
$indexes_info[$row['Key_name']]['Index_type'] = isset($row['Index_type']) ? $row['Index_type'] : '';
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
if (isset($row['Sub_part'])) {
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
}
}
// end while
// do we have any index?
if (isset($indexes_data)) {
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
$span = $fields_cnt;
if ($is_display['edit_lnk'] != 'nn') {
$span++;
}
if ($is_display['del_lnk'] != 'nn') {
$span++;
}
if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') {
$span++;
}
} else {
$span = $num_rows + floor($num_rows / $repeat_cells) + 1;
}
echo '<form action="sql.php" method="post">' . "\n";
echo PMA_generate_common_hidden_inputs($db, $table, 5);
echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
//.........这里部分代码省略.........
示例3: PMA_displayTable
$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;
?>
示例4: PMA_generate_common_url
require_once './header.inc.php';
}
// end if
/**
* Gets fields and indexes informations
*/
if (!defined('PMA_IDX_INCLUDED')) {
$err_url_0 = 'db_details.php?' . PMA_generate_common_url($db);
}
// Gets table keys and store them in arrays
$indexes = array();
$indexes_info = array();
$indexes_data = array();
// keys had already been grabbed in "tbl_properties.php"
if (!defined('PMA_IDX_INCLUDED')) {
$ret_keys = PMA_get_indexes($table, $err_url_0);
}
PMA_extract_indexes($ret_keys, $indexes, $indexes_info, $indexes_data);
// Get fields and stores their name/type
// fields had already been grabbed in "tbl_properties.php"
if (!defined('PMA_IDX_INCLUDED')) {
$fields_rs = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
$save_row = array();
while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
$save_row[] = $row;
}
}
$fields_names = array();
$fields_types = array();
foreach ($save_row as $saved_row_key => $row) {
$fields_names[] = $row['Field'];
示例5: get_all_keys
function get_all_keys()
{
global $db;
require_once './libs/tbl_indexes.lib.php';
PMA_DBI_select_db($db);
$tables_all_keys = array();
for ($I = 0; $I < sizeof($GLOBALS['PMD']['TABLE_NAME_SMALL']); $I++) {
$ret_keys = PMA_get_indexes($GLOBALS['PMD']['TABLE_NAME_SMALL'][$I]);
if (!empty($ret_keys)) {
// reset those as the function uses them by reference
$indexes = $indexes_info = $indexes_data = array();
PMA_extract_indexes($ret_keys, $indexes, $indexes_info, $indexes_data);
// for now, take into account only the first index segment
foreach ($indexes_data as $one_index) {
$column_name = $one_index[1]['Column_name'];
$tables_all_keys[$GLOBALS['PMD']['OWNER'][$I] . '.' . $GLOBALS['PMD']['TABLE_NAME_SMALL'][$I] . '.' . $column_name] = 1;
}
}
}
return $tables_all_keys;
}