* Get columns names */ $columns = $GLOBALS['dbi']->getColumns($GLOBALS['db'], $GLOBALS['table']); /** * Displays the page */ $response->addHTML('<div id="boxContainer" data-box-width="300">'); /** * Order the table */ $hideOrderTable = false; // `ALTER TABLE ORDER BY` does not make sense for InnoDB tables that contain // a user-defined clustered index (PRIMARY KEY or NOT NULL UNIQUE index). // InnoDB always orders table rows according to such an index if one is present. if ($tbl_storage_engine == 'INNODB') { $indexes = PMA\libraries\Index::getFromTable($GLOBALS['table'], $GLOBALS['db']); foreach ($indexes as $name => $idx) { if ($name == 'PRIMARY') { $hideOrderTable = true; break; } elseif (!$idx->getNonUnique()) { $notNull = true; foreach ($idx->getColumns() as $column) { if ($column->getNull()) { $notNull = false; break; } } if ($notNull) { $hideOrderTable = true; break;
/** * Verify whether the result set contains all the columns * of at least one unique key * * @param string $db database name * @param string $table table name * @param array $fields_meta meta fields * * @return boolean whether the result set contains a unique key */ function PMA_resultSetContainsUniqueKey($db, $table, $fields_meta) { $resultSetColumnNames = array(); foreach ($fields_meta as $oneMeta) { $resultSetColumnNames[] = $oneMeta->name; } foreach (PMA\libraries\Index::getFromTable($table, $db) as $index) { if ($index->isUnique()) { $indexColumns = $index->getColumns(); $numberFound = 0; foreach ($indexColumns as $indexColumnName => $dummy) { if (in_array($indexColumnName, $resultSetColumnNames)) { $numberFound++; } } if ($numberFound == count($indexColumns)) { return true; } } } return false; }
echo '</td>', "\n"; } echo ' <td>'; if (isset($comments[$column_name])) { echo htmlspecialchars($comments[$column_name]); } echo '</td>', "\n"; if ($cfgRelation['mimework']) { $mime_map = PMA_getMIME($db, $table, true); echo ' <td>'; if (isset($mime_map[$column_name])) { echo htmlspecialchars(str_replace('_', '/', $mime_map[$column_name]['mimetype'])); } echo '</td>', "\n"; } echo '</tr>'; } // end foreach $count++; echo '</table>'; // display indexes information if (count(PMA\libraries\Index::getFromTable($table, $db)) > 0) { echo PMA\libraries\Index::getHtmlForIndexes($table, $db, true); } echo '</div>'; } //ends main while /** * Displays the footer */ echo PMA\libraries\Util::getButton();
/** * Returns all indices * * @param bool $unique_only whether to include only unique ones * * @return array indices */ function PMA_getAllKeys($unique_only = false) { $keys = array(); foreach ($GLOBALS['PMD']['TABLE_NAME_SMALL'] as $I => $table) { $schema = $GLOBALS['PMD']['OWNER'][$I]; // for now, take into account only the first index segment foreach (PMA\libraries\Index::getFromTable($table, $schema) as $index) { if ($unique_only && !$index->isUnique()) { continue; } $columns = $index->getColumns(); foreach ($columns as $column_name => $dummy) { $keys[$schema . '.' . $table . '.' . $column_name] = 1; } } } return $keys; }