本文整理汇总了PHP中PMA_Index::getPrimary方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Index::getPrimary方法的具体用法?PHP PMA_Index::getPrimary怎么用?PHP PMA_Index::getPrimary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA_Index
的用法示例。
在下文中一共展示了PMA_Index::getPrimary方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_getDefaultSqlQueryForBrowse
/**
* Function to get the default sql query for browsing page
*
* @param String $db the current database
* @param String $table the current table
*
* @return String $sql_query the default $sql_query for browse page
*/
function PMA_getDefaultSqlQueryForBrowse($db, $table)
{
include_once 'libraries/bookmark.lib.php';
$book_sql_query = PMA_Bookmark_get($db, '\'' . PMA_Util::sqlAddSlashes($table) . '\'', 'label', false, true);
if (!empty($book_sql_query)) {
$GLOBALS['using_bookmark_message'] = PMA_message::notice(__('Using bookmark "%s" as default browse query.'));
$GLOBALS['using_bookmark_message']->addParam($table);
$GLOBALS['using_bookmark_message']->addMessage(PMA_Util::showDocu('faq', 'faq6-22'));
$sql_query = $book_sql_query;
} else {
$defaultOrderByClause = '';
if (isset($GLOBALS['cfg']['TablePrimaryKeyOrder']) && $GLOBALS['cfg']['TablePrimaryKeyOrder'] !== 'NONE') {
$primaryKey = null;
$primary = PMA_Index::getPrimary($table, $db);
if ($primary !== false) {
$primarycols = $primary->getColumns();
foreach ($primarycols as $col) {
$primaryKey = $col->getName();
break;
}
if ($primaryKey != null) {
$defaultOrderByClause = ' ORDER BY ' . PMA_Util::backquote($table) . '.' . PMA_Util::backquote($primaryKey) . ' ' . $GLOBALS['cfg']['TablePrimaryKeyOrder'];
}
}
}
$sql_query = 'SELECT * FROM ' . PMA_Util::backquote($table) . $defaultOrderByClause;
}
unset($book_sql_query);
return $sql_query;
}
示例2: PMA_getHtmlForPrintViewColumns
/**
* return html for Print View Columns
*
* @param bool $tbl_is_view whether table is a view
* @param array $columns columns list
* @param array $analyzed_sql analyzed sql
* @param bool $have_rel have relation?
* @param array $res_rel relations array
* @param string $db database name
* @param string $table table name
* @param array $cfgRelation config from PMA_getRelationsParam
*
* @return string
*/
function PMA_getHtmlForPrintViewColumns($tbl_is_view, $columns, $analyzed_sql, $have_rel, $res_rel, $db, $table, $cfgRelation)
{
$html = '';
$primary = PMA_Index::getPrimary($table, $db);
foreach ($columns as $row) {
$extracted_columnspec = PMA_Util::extractColumnSpec($row['Type']);
$type = $extracted_columnspec['print_type'];
if (!isset($row['Default'])) {
if ($row['Null'] != '' && $row['Null'] != 'NO') {
$row['Default'] = '<i>NULL</i>';
}
} else {
$row['Default'] = htmlspecialchars($row['Default']);
}
$field_name = htmlspecialchars($row['Field']);
if (!$tbl_is_view) {
// here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as having
// the NULL attribute, but SHOW CREATE TABLE says the contrary.
// Believe the latter.
/**
* @todo merge this logic with the one in tbl_structure.php
* or move it in a function similar to $GLOBALS['dbi']->getColumnsFull()
* but based on SHOW CREATE TABLE because information_schema
* cannot be trusted in this case (MySQL bug)
*/
$analyzed_for_field = $analyzed_sql[0]['create_table_fields'][$field_name];
if (!empty($analyzed_for_field['type']) && $analyzed_for_field['type'] == 'TIMESTAMP' && $analyzed_for_field['timestamp_not_null']) {
$row['Null'] = '';
}
}
$html .= "\n";
$html .= '<tr><td>';
$html .= ' ' . $field_name . "\n";
if ($primary && $primary->hasColumn($field_name)) {
$html .= ' <em>(' . __('Primary') . ')</em>';
}
$html .= "\n";
$html .= '</td>';
$html .= '<td>' . htmlspecialchars($type) . '<bdo dir="ltr"></bdo></td>';
$html .= '<td>';
$html .= $row['Null'] == '' || $row['Null'] == 'NO' ? __('No') : __('Yes');
$html .= ' </td>';
$html .= '<td>';
if (isset($row['Default'])) {
$html .= $row['Default'];
}
$html .= ' </td>';
if ($have_rel) {
$html .= ' <td>';
$foreigner = PMA_searchColumnInForeigners($res_rel, $field_name);
if ($foreigner) {
$html .= htmlspecialchars($foreigner['foreign_table'] . ' -> ' . $foreigner['foreign_field']);
}
$html .= ' </td>' . "\n";
}
$html .= ' <td>';
$comments = PMA_getComments($db, $table);
if (isset($comments[$field_name])) {
$html .= htmlspecialchars($comments[$field_name]);
}
$html .= ' </td>' . "\n";
if ($cfgRelation['mimework']) {
$mime_map = PMA_getMIME($db, $table, true);
$html .= ' <td>';
if (isset($mime_map[$field_name])) {
$html .= htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype']));
}
$html .= ' </td>' . "\n";
}
$html .= '</tr>';
}
// end foreach
return $html;
}
示例3:
$url_params['back'] = 'tbl_structure.php';
/**
* Prepares the table structure display
*/
/**
* Gets tables informations
*/
require_once './libraries/tbl_info.inc.php';
/**
* Displays top menu links
*/
require_once './libraries/tbl_links.inc.php';
require_once './libraries/Index.class.php';
// 2. Gets table keys and retains them
// @todo should be: $server->db($db)->table($table)->primary()
$primary = PMA_Index::getPrimary($table, $db);
// 3. Get fields
$fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
$fields_cnt = PMA_DBI_num_rows($fields_rs);
// Get more complete field information
// For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
// but later, if the analyser returns more information, it
// could be executed for any MySQL version and replace
// the info given by SHOW FULL FIELDS FROM.
//
// We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
// SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
// and SHOW CREATE TABLE says NOT NULL (tested
// in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
$show_create_table = PMA_DBI_fetch_value('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0, 1);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
示例4: PMA_sendHtmlForColumnDropdownList
/**
* Function to send html for column dropdown list
*
* @return void
*/
function PMA_sendHtmlForColumnDropdownList()
{
$response = PMA_Response::getInstance();
$foreignTable = $_REQUEST['foreignTable'];
$table_obj = new PMA_Table($foreignTable, $_REQUEST['foreignDb']);
// Since views do not have keys defined on them provide the full list of columns
if (PMA_Table::isView($_REQUEST['foreignDb'], $foreignTable)) {
$columnList = $table_obj->getColumns(false, false);
} else {
$columnList = $table_obj->getIndexedColumns(false, false);
}
$columns = array();
foreach ($columnList as $column) {
$columns[] = htmlspecialchars($column);
}
$response->addJSON('columns', $columns);
// @todo should be: $server->db($db)->table($table)->primary()
$primary = PMA_Index::getPrimary($foreignTable, $_REQUEST['foreignDb']);
if (false === $primary) {
return;
}
$primarycols = array_keys($primary->getColumns());
$response->addJSON('primary', $primarycols);
}
示例5: generateIndexSelector
public function generateIndexSelector()
{
$html_options = '';
foreach (PMA_Index::getIndexChoices() as $each_index_choice) {
if ($each_index_choice === 'PRIMARY' && $this->_choice !== 'PRIMARY' && PMA_Index::getPrimary($this->_table, $this->_schema)) {
// skip PRIMARY if there is already one in the table
continue;
}
$html_options .= '<option value="' . $each_index_choice . '"' . ($this->_choice == $each_index_choice ? ' selected="selected"' : '') . '>' . $each_index_choice . '</option>' . "\n";
}
return $html_options;
}
示例6: PMA_findPartialDependencies
/**
* find all the possible partial dependencies based on data in the table.
*
* @param string $table current table
* @param string $db current database
*
* @return HTML containing the list of all the possible partial dependencies
*/
function PMA_findPartialDependencies($table, $db)
{
$dependencyList = array();
$GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
$columns = (array) $GLOBALS['dbi']->getColumnNames($db, $table, $GLOBALS['userlink']);
$columns = (array) PMA_Util::backquote($columns);
$totalRowsRes = $GLOBALS['dbi']->fetchResult('SELECT COUNT(*) FROM (SELECT * FROM ' . PMA_Util::backquote($table) . ' LIMIT 500) as dt;');
$totalRows = $totalRowsRes[0];
$primary = PMA_Index::getPrimary($table, $db);
$primarycols = $primary->getColumns();
$pk = array();
foreach ($primarycols as $col) {
$pk[] = PMA_Util::backquote($col->getName());
}
$partialKeys = PMA_getAllCombinationPartialKeys($pk);
$distinctValCount = PMA_findDistinctValuesCount(array_unique(array_merge($columns, $partialKeys)), $table);
foreach ($columns as $column) {
if (!in_array($column, $pk)) {
foreach ($partialKeys as $partialKey) {
if ($partialKey && PMA_checkPartialDependency($partialKey, $column, $table, $distinctValCount[$partialKey], $distinctValCount[$column], $totalRows)) {
$dependencyList[$partialKey][] = $column;
}
}
}
}
$html = __('This list is based on a subset of the table\'s data ' . 'and is not necessarily accurate. ') . '<div class="dependencies_box">';
foreach ($dependencyList as $dependon => $colList) {
$html .= '<span class="displayblock">' . '<input type="button" class="pickPd" value="' . __('Pick') . '"/>' . '<span class="determinants">' . htmlspecialchars(str_replace('`', '', $dependon)) . '</span> -> ' . '<span class="dependents">' . htmlspecialchars(str_replace('`', '', implode(', ', $colList))) . '</span>' . '</span>';
}
if (empty($dependencyList)) {
$html .= '<p class="displayblock desc">' . __('No partial dependencies found!') . '</p>';
}
$html .= '</div>';
return $html;
}
示例7: PMA_Table
// if both db and table are selected
$foreignTable = $_REQUEST['foreignTable'];
$table_obj = new PMA_Table($foreignTable, $_REQUEST['foreignDb']);
// Since views do not have keys defined on them provide the full list of columns
if (PMA_Table::isView($_REQUEST['foreignDb'], $foreignTable)) {
$columnList = $table_obj->getColumns(false, false);
} else {
$columnList = $table_obj->getIndexedColumns(false, false);
}
$columns = array();
foreach ($columnList as $column) {
$columns[] = htmlspecialchars($column);
}
$response->addJSON('columns', $columns);
// @todo should be: $server->db($db)->table($table)->primary()
$primary = PMA_Index::getPrimary($foreignTable, $_REQUEST['foreignDb']);
if (false === $primary) {
return;
}
$primarycols = array_keys($primary->getColumns());
$response->addJSON('primary', $primarycols);
} else {
// if only the db is selected
$tables = array();
$foreign = isset($_REQUEST['foreign']) && $_REQUEST['foreign'] === 'true';
if ($foreign) {
$tbl_storage_engine = mb_strtoupper(PMA_Table::sGetStatusInfo($_REQUEST['db'], $_REQUEST['table'], 'Engine'));
}
// In Drizzle, 'SHOW TABLE STATUS' will show status only for the tables
// which are currently in the table cache. Hence we have to use 'SHOW TABLES'
// and manually retrieve table engine values.