本文整理汇总了PHP中PMA_Table类的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Table类的具体用法?PHP PMA_Table怎么用?PHP PMA_Table使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPMAGetSqlQueryForIndexCreateOrEdit
/**
* Tests for PMA_getSqlQueryForIndexCreateOrEdit() method.
*
* @return void
* @test
*/
public function testPMAGetSqlQueryForIndexCreateOrEdit()
{
$db = "pma_db";
$table = "pma_table";
$index = new PMA_Index();
$error = false;
$_REQUEST['old_index'] = "PRIMARY";
$table = new PMA_Table($table, $db);
$sql = $table->getSqlQueryForIndexCreateOrEdit($index, $error);
$this->assertEquals("ALTER TABLE `pma_db`.`pma_table` DROP PRIMARY KEY, ADD UNIQUE ;", $sql);
}
示例2: PMA_buildColumnCreationStatement
/**
* Initiate the column creation statement according to the table creation or
* add columns to a existing table
*
* @param int $field_cnt number of columns
* @param int &$field_primary primary index field
* @param boolean $is_create_tbl true if requirement is to get the statement
* for table creation
*
* @return array $definitions An array of initial sql statements
* according to the request
*/
function PMA_buildColumnCreationStatement($field_cnt, &$field_primary, $is_create_tbl = true)
{
$definitions = array();
for ($i = 0; $i < $field_cnt; ++$i) {
// '0' is also empty for php :-(
if (empty($_REQUEST['field_name'][$i]) && $_REQUEST['field_name'][$i] != '0') {
continue;
}
$definition = PMA_getStatementPrefix($is_create_tbl) . PMA_Table::generateFieldSpec($_REQUEST['field_name'][$i], $_REQUEST['field_type'][$i], $i, $_REQUEST['field_length'][$i], $_REQUEST['field_attribute'][$i], isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '', isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : 'NOT NULL', $_REQUEST['field_default_type'][$i], $_REQUEST['field_default_value'][$i], isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false, isset($_REQUEST['field_comments'][$i]) ? $_REQUEST['field_comments'][$i] : '', $field_primary);
$definition .= PMA_setColumnCreationStatementSuffix($i, $is_create_tbl);
$definitions[] = $definition;
}
// end for
return $definitions;
}
示例3: PMA_Table
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
*
* @package PhpMyAdmin
*/
/**
*
*/
require_once './libraries/common.inc.php';
$pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
/**
* Runs common work
*/
require './libraries/tbl_common.inc.php';
$url_query .= '&goto=view_operations.php&back=view_operations.php';
$url_params['goto'] = $url_params['back'] = 'view_operations.php';
/**
* Gets tables informations
*/
require './libraries/tbl_info.inc.php';
$reread_info = false;
/**
* Updates if required
*/
示例4: PMA_getForeignData
/**
* Gets foreign keys in preparation for a drop-down selector
*
* @param array|boolean $foreigners array of the foreign keys
* @param string $field the foreign field name
* @param bool $override_total whether to override the total
* @param string $foreign_filter a possible filter
* @param string $foreign_limit a possible LIMIT clause
*
* @return array data about the foreign keys
*
* @access public
*/
function PMA_getForeignData($foreigners, $field, $override_total, $foreign_filter, $foreign_limit)
{
// we always show the foreign field in the drop-down; if a display
// field is defined, we show it besides the foreign field
$foreign_link = false;
do {
if (!$foreigners) {
break;
}
$foreigner = PMA_searchColumnInForeigners($foreigners, $field);
if ($foreigner != false) {
$foreign_db = $foreigner['foreign_db'];
$foreign_table = $foreigner['foreign_table'];
$foreign_field = $foreigner['foreign_field'];
} else {
break;
}
// Count number of rows in the foreign table. Currently we do
// not use a drop-down if more than ForeignKeyMaxLimit rows in the
// foreign table,
// for speed reasons and because we need a better interface for this.
//
// We could also do the SELECT anyway, with a LIMIT, and ensure that
// the current value of the field is one of the choices.
$the_total = PMA_Table::countRecords($foreign_db, $foreign_table, true);
if ($override_total == true || $the_total < $GLOBALS['cfg']['ForeignKeyMaxLimit']) {
// foreign_display can be false if no display field defined:
$foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
$f_query_main = 'SELECT ' . PMA_Util::backquote($foreign_field) . ($foreign_display == false ? '' : ', ' . PMA_Util::backquote($foreign_display));
$f_query_from = ' FROM ' . PMA_Util::backquote($foreign_db) . '.' . PMA_Util::backquote($foreign_table);
$f_query_filter = empty($foreign_filter) ? '' : ' WHERE ' . PMA_Util::backquote($foreign_field) . ' LIKE "%' . PMA_Util::sqlAddSlashes($foreign_filter, true) . '%"' . ($foreign_display == false ? '' : ' OR ' . PMA_Util::backquote($foreign_display) . ' LIKE "%' . PMA_Util::sqlAddSlashes($foreign_filter, true) . '%"');
$f_query_order = $foreign_display == false ? '' : ' ORDER BY ' . PMA_Util::backquote($foreign_table) . '.' . PMA_Util::backquote($foreign_display);
$f_query_limit = isset($foreign_limit) ? $foreign_limit : '';
if (!empty($foreign_filter)) {
$the_total = $GLOBALS['dbi']->fetchValue('SELECT COUNT(*)' . $f_query_from . $f_query_filter);
if ($the_total === false) {
$the_total = 0;
}
}
$disp = $GLOBALS['dbi']->tryQuery($f_query_main . $f_query_from . $f_query_filter . $f_query_order . $f_query_limit);
if ($disp && $GLOBALS['dbi']->numRows($disp) > 0) {
// If a resultset has been created, pre-cache it in the $disp_row
// array. This helps us from not needing to use mysql_data_seek by
// accessing a pre-cached PHP array. Usually those resultsets are
// not that big, so a performance hit should not be expected.
$disp_row = array();
while ($single_disp_row = @$GLOBALS['dbi']->fetchAssoc($disp)) {
$disp_row[] = $single_disp_row;
}
@$GLOBALS['dbi']->freeResult($disp);
} else {
// Either no data in the foreign table or
// user does not have select permission to foreign table/field
// Show an input field with a 'Browse foreign values' link
$disp_row = null;
$foreign_link = true;
}
} else {
$disp_row = null;
$foreign_link = true;
}
} while (false);
$foreignData = array();
$foreignData['foreign_link'] = $foreign_link;
$foreignData['the_total'] = isset($the_total) ? $the_total : null;
$foreignData['foreign_display'] = isset($foreign_display) ? $foreign_display : null;
$foreignData['disp_row'] = isset($disp_row) ? $disp_row : null;
$foreignData['foreign_field'] = isset($foreign_field) ? $foreign_field : null;
return $foreignData;
}
示例5: _setMessageInformation
/**
* Set the content that needs to be shown in message
*
* @param string $sorted_column_message the message for sorted column
* @param string $limit_clause the limit clause of analyzed query
* @param integer $total the total number of rows returned by
* the SQL query without any
* programmatically appended LIMIT clause
* @param integer $pos_next the offset for next page
* @param string $pre_count the string renders before row count
* @param string $after_count the string renders after row count
*
* @return PMA_Message $message an object of PMA_Message
*
* @access private
*
* @see getTable()
*/
private function _setMessageInformation($sorted_column_message, $limit_clause, $total, $pos_next, $pre_count, $after_count)
{
$unlim_num_rows = $this->__get('unlim_num_rows');
// To use in isset()
if (!empty($limit_clause)) {
$limit_data = PMA_Util::analyzeLimitClause($limit_clause);
$first_shown_rec = $limit_data['start'];
if ($limit_data['length'] < $total) {
$last_shown_rec = $limit_data['start'] + $limit_data['length'] - 1;
} else {
$last_shown_rec = $limit_data['start'] + $total - 1;
}
} elseif ($_SESSION['tmpval']['max_rows'] == self::ALL_ROWS || $pos_next > $total) {
$first_shown_rec = $_SESSION['tmpval']['pos'];
$last_shown_rec = $total - 1;
} else {
$first_shown_rec = $_SESSION['tmpval']['pos'];
$last_shown_rec = $pos_next - 1;
}
if (PMA_Table::isView($this->__get('db'), $this->__get('table')) && $total == $GLOBALS['cfg']['MaxExactCountViews']) {
$message = PMA_Message::notice(__('This view has at least this number of rows. ' . 'Please refer to %sdocumentation%s.'));
$message->addParam('[doc@cfg_MaxExactCount]');
$message->addParam('[/doc]');
$message_view_warning = PMA_Util::showHint($message);
} else {
$message_view_warning = false;
}
$message = PMA_Message::success(__('Showing rows %1s - %2s'));
$message->addParam($first_shown_rec);
if ($message_view_warning) {
$message->addParam('... ' . $message_view_warning, false);
} else {
$message->addParam($last_shown_rec);
}
$message->addMessage('(');
if (!$message_view_warning) {
if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
$message_total = PMA_Message::notice($pre_count . __('%1$d total, %2$d in query'));
$message_total->addParam($total);
$message_total->addParam($unlim_num_rows);
} else {
$message_total = PMA_Message::notice($pre_count . __('%d total'));
$message_total->addParam($total);
}
if (!empty($after_count)) {
$message_total->addMessage($after_count);
}
$message->addMessage($message_total, '');
$message->addMessage(', ', '');
}
$message_qt = PMA_Message::notice(__('Query took %01.4f seconds.') . ')');
$message_qt->addParam($this->__get('querytime'));
$message->addMessage($message_qt, '');
if (!is_null($sorted_column_message)) {
$message->addMessage($sorted_column_message, '');
}
return $message;
}
示例6: rename
/**
* renames table
*
* @param string new table name
* @param string new database name
* @return boolean success
*/
function rename($new_name, $new_db = null)
{
if (null !== $new_db && $new_db !== $this->getDbName()) {
// Ensure the target is valid
if (!$GLOBALS['PMA_List_Database']->exists($new_db)) {
$this->errors[] = $GLOBALS['strInvalidDatabase'] . ': ' . $new_db;
return false;
}
} else {
$new_db = $this->getDbName();
}
$new_table = new PMA_Table($new_name, $new_db);
if ($this->getFullName() === $new_table->getFullName()) {
return true;
}
if (!PMA_Table::isValidName($new_name)) {
$this->errors[] = $GLOBALS['strInvalidTableName'] . ': ' . $new_table->getFullName();
return false;
}
$GLOBALS['sql_query'] = '
RENAME TABLE ' . $this->getFullName(true) . '
TO ' . $new_table->getFullName(true) . ';';
if (!PMA_DBI_query($GLOBALS['sql_query'])) {
$this->errors[] = sprintf($GLOBALS['strErrorRenamingTable'], $this->getFullName(), $new_table->getFullName());
return false;
}
$old_name = $this->getName();
$old_db = $this->getDbName();
$this->setName($new_name);
$this->setDbName($new_db);
/**
* @todo move into extra function PMA_Relation::renameTable($new_name, $old_name, $new_db, $old_db)
*/
// garvin: Move old entries from comments to new table
require_once './libraries/relation.lib.php';
$GLOBALS['cfgRelation'] = PMA_getRelationsParam();
if ($GLOBALS['cfgRelation']['commwork']) {
$remove_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info']) . '
SET `db_name` = \'' . PMA_sqlAddslashes($new_db) . '\',
`table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `db_name` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($remove_query);
unset($remove_query);
}
if ($GLOBALS['cfgRelation']['displaywork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['table_info']) . '
SET `db_name` = \'' . PMA_sqlAddslashes($new_db) . '\',
`table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `db_name` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
unset($table_query);
}
if ($GLOBALS['cfgRelation']['relwork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['relation']) . '
SET `foreign_db` = \'' . PMA_sqlAddslashes($new_db) . '\',
`foreign_table` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `foreign_db` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `foreign_table` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['relation']) . '
SET `master_db` = \'' . PMA_sqlAddslashes($new_db) . '\',
`master_table` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `master_db` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `master_table` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
unset($table_query);
}
if ($GLOBALS['cfgRelation']['pdfwork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['table_coords']) . '
SET `db_name` = \'' . PMA_sqlAddslashes($new_db) . '\',
`table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `db_name` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
unset($table_query);
}
if ($GLOBALS['cfgRelation']['designerwork']) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['designer_coords']) . '
SET `db_name` = \'' . PMA_sqlAddslashes($new_db) . '\',
`table_name` = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE `db_name` = \'' . PMA_sqlAddslashes($old_db) . '\'
AND `table_name` = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
unset($table_query);
}
//.........这里部分代码省略.........
示例7: isset
$field_index[] = $i;
}
if (${'field_key_' . $i} == 'unique_' . $i) {
$field_unique[] = $i;
}
}
// end if
}
// end for
// Builds the fields creation statements
for ($i = 0; $i < $field_cnt; $i++) {
// '0' is also empty for php :-(
if (empty($field_name[$i]) && $field_name[$i] != '0') {
continue;
}
$query = PMA_Table::generateFieldSpec($field_name[$i], $field_type[$i], $field_length[$i], $field_attribute[$i], isset($field_collation[$i]) ? $field_collation[$i] : '', $field_null[$i], $field_default[$i], isset($field_default_current_timestamp[$i]), $field_extra[$i], isset($field_comments[$i]) ? $field_comments[$i] : '', $field_primary, $i);
$query .= ', ';
$sql_query .= $query;
$query_cpy .= "\n" . ' ' . $query;
}
// end for
unset($field_cnt);
unset($query);
$sql_query = preg_replace('@, $@', '', $sql_query);
$query_cpy = preg_replace('@, $@', '', $query_cpy);
// Builds the primary keys statements
$primary = '';
$primary_cnt = isset($field_primary) ? count($field_primary) : 0;
for ($i = 0; $i < $primary_cnt; $i++) {
$j = $field_primary[$i];
if (isset($field_name[$j]) && strlen($field_name[$j])) {
示例8: PMA_generate_common_url
/**
* Defines the url to return to in case of error in a sql statement
*/
$err_url = 'tbl_sql.php?' . PMA_generate_common_url($db, $table);
/**
* Selects the database to work with
*/
PMA_DBI_select_db($db);
/**
* A target table name has been sent to this script -> do the work
*/
if (isset($new_name) && trim($new_name) != '') {
if ($db == $target_db && $table == $new_name) {
$message = isset($submit_move) ? $strMoveTableSameNames : $strCopyTableSameNames;
} else {
PMA_Table::moveCopy($db, $table, $target_db, $new_name, $what, isset($submit_move), 'one_table');
$js_to_run = 'functions.js';
$message = isset($submit_move) ? $strMoveTableOK : $strCopyTableOK;
$message = sprintf($message, htmlspecialchars($table), htmlspecialchars($new_name));
$reload = 1;
/* Check: Work on new table or on old table? */
if (isset($submit_move)) {
$db = $target_db;
$table = $new_name;
} else {
$pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
if (isset($switch_to_new) && $switch_to_new == 'true') {
PMA_setCookie('pma_switch_to_new', 'true');
$db = $target_db;
$table = $new_name;
} else {
示例9: PMA_saveDisplayField
/**
* Saves the display field for a table.
*
* @param string $db database name
* @param string $table table name
* @param string $field display field name
*
* @return boolean
*/
function PMA_saveDisplayField($db, $table, $field)
{
$cfgRelation = PMA_getRelationsParam();
if (!$cfgRelation['displaywork']) {
return false;
}
$disp = PMA_getDisplayField($db, $table);
if ($disp && $disp === $field) {
$field = '';
}
$upd_query = new PMA_Table($table, $db, $GLOBALS['dbi']);
$upd_query->updateDisplayField($disp, $field, $cfgRelation);
return true;
}
示例10: foreach
} else {
$col_cand = $sg;
// None of the candidates where in a where-clause
}
}
// If our array of candidates has more than one member we'll just
// find the smallest table.
// Of course the actual query would be faster if we check for
// the Criteria which gives the smallest result set in its table,
// but it would take too much time to check this
if (count($col_cand) > 1) {
// Of course we only want to check each table once
$checked_tables = $col_cand;
foreach ($col_cand as $tab) {
if ($checked_tables[$tab] != 1) {
$tsize[$tab] = PMA_Table::countRecords($db, $tab, true, false);
$checked_tables[$tab] = 1;
}
$csize[$tab] = $tsize[$tab];
}
asort($csize);
reset($csize);
$master = key($csize);
// Smallest
} else {
reset($col_cand);
$master = current($col_cand);
// Only one single candidate
}
}
// end if (exactly one where clause)
示例11: PMA_getHtmlForExportOptions
/**
* Prints Html For Export Options
*
* @param String $export_type Selected Export Type
* @param String $db Selected DB
* @param String $table Selected Table
* @param String $multi_values Export selection
* @param String $num_tables number of tables
* @param ExportPlugin[] $export_list Export List
* @param String $unlim_num_rows Number of Rows
*
* @return string
*/
function PMA_getHtmlForExportOptions($export_type, $db, $table, $multi_values, $num_tables, $export_list, $unlim_num_rows)
{
global $cfg;
$html = PMA_getHtmlForExportOptionsMethod();
$html .= PMA_getHtmlForExportOptionsFormatDropdown($export_list);
$html .= PMA_getHtmlForExportOptionsSelection($export_type, $multi_values);
$tableLength = mb_strlen($table);
if ($tableLength && empty($num_tables) && !PMA_Table::isMerge($db, $table)) {
$html .= PMA_getHtmlForExportOptionsRows($db, $table, $unlim_num_rows);
}
if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
$html .= PMA_getHtmlForExportOptionsQuickExport();
}
$html .= PMA_getHtmlForAliasModalDialog($db, $table);
$html .= PMA_getHtmlForExportOptionsOutput($export_type);
$html .= PMA_getHtmlForExportOptionsFormat($export_list);
return $html;
}
示例12: PMA_DBI_get_tables_full
//.........这里部分代码省略.........
$sql = 'SHOW TABLE STATUS FROM ' . PMA_backquote($each_database);
}
$each_tables = PMA_DBI_fetch_result($sql, 'Name', null, $link);
// Sort naturally if the config allows it and we're sorting
// the Name column.
if ($sort_by == 'Name' && $GLOBALS['cfg']['NaturalOrder']) {
uksort($each_tables, 'strnatcasecmp');
if ($sort_order == 'DESC') {
$each_tables = array_reverse($each_tables);
}
} else {
// Prepare to sort by creating array of the selected sort
// value to pass to array_multisort
foreach ($each_tables as $table_name => $table_data) {
${$sort_by}[$table_name] = strtolower($table_data[$sort_by]);
}
if ($sort_order == 'DESC') {
array_multisort(${$sort_by}, SORT_DESC, $each_tables);
} else {
array_multisort(${$sort_by}, SORT_ASC, $each_tables);
}
// cleanup the temporary sort array
unset(${$sort_by});
}
if ($limit_count) {
$each_tables = array_slice($each_tables, $limit_offset, $limit_count);
}
foreach ($each_tables as $table_name => $each_table) {
if ('comment' === $tbl_is_group && 0 === strpos($each_table['Comment'], $table)) {
// remove table from list
unset($each_tables[$table_name]);
continue;
}
if (!isset($each_tables[$table_name]['Type']) && isset($each_tables[$table_name]['Engine'])) {
// pma BC, same parts of PMA still uses 'Type'
$each_tables[$table_name]['Type'] =& $each_tables[$table_name]['Engine'];
} elseif (!isset($each_tables[$table_name]['Engine']) && isset($each_tables[$table_name]['Type'])) {
// old MySQL reports Type, newer MySQL reports Engine
$each_tables[$table_name]['Engine'] =& $each_tables[$table_name]['Type'];
}
// MySQL forward compatibility
// so pma could use this array as if every server is of version >5.0
$each_tables[$table_name]['TABLE_SCHEMA'] = $each_database;
$each_tables[$table_name]['TABLE_NAME'] =& $each_tables[$table_name]['Name'];
$each_tables[$table_name]['ENGINE'] =& $each_tables[$table_name]['Engine'];
$each_tables[$table_name]['VERSION'] =& $each_tables[$table_name]['Version'];
$each_tables[$table_name]['ROW_FORMAT'] =& $each_tables[$table_name]['Row_format'];
$each_tables[$table_name]['TABLE_ROWS'] =& $each_tables[$table_name]['Rows'];
$each_tables[$table_name]['AVG_ROW_LENGTH'] =& $each_tables[$table_name]['Avg_row_length'];
$each_tables[$table_name]['DATA_LENGTH'] =& $each_tables[$table_name]['Data_length'];
$each_tables[$table_name]['MAX_DATA_LENGTH'] =& $each_tables[$table_name]['Max_data_length'];
$each_tables[$table_name]['INDEX_LENGTH'] =& $each_tables[$table_name]['Index_length'];
$each_tables[$table_name]['DATA_FREE'] =& $each_tables[$table_name]['Data_free'];
$each_tables[$table_name]['AUTO_INCREMENT'] =& $each_tables[$table_name]['Auto_increment'];
$each_tables[$table_name]['CREATE_TIME'] =& $each_tables[$table_name]['Create_time'];
$each_tables[$table_name]['UPDATE_TIME'] =& $each_tables[$table_name]['Update_time'];
$each_tables[$table_name]['CHECK_TIME'] =& $each_tables[$table_name]['Check_time'];
$each_tables[$table_name]['TABLE_COLLATION'] =& $each_tables[$table_name]['Collation'];
$each_tables[$table_name]['CHECKSUM'] =& $each_tables[$table_name]['Checksum'];
$each_tables[$table_name]['CREATE_OPTIONS'] =& $each_tables[$table_name]['Create_options'];
$each_tables[$table_name]['TABLE_COMMENT'] =& $each_tables[$table_name]['Comment'];
if (strtoupper($each_tables[$table_name]['Comment']) === 'VIEW' && $each_tables[$table_name]['Engine'] == NULL) {
$each_tables[$table_name]['TABLE_TYPE'] = 'VIEW';
} else {
/**
* @todo difference between 'TEMPORARY' and 'BASE TABLE' but how to detect?
*/
$each_tables[$table_name]['TABLE_TYPE'] = 'BASE TABLE';
}
}
$tables[$each_database] = $each_tables;
}
}
// cache table data
// so PMA_Table does not require to issue SHOW TABLE STATUS again
// Note: I don't see why we would need array_merge_recursive() here,
// as it creates double entries for the same table (for example a double
// entry for Comment when changing the storage engine in Operations)
// Note 2: Instead of array_merge(), simply use the + operator because
// array_merge() renumbers numeric keys starting with 0, therefore
// we would lose a db name thats consists only of numbers
PMA_Table::$cache = PMA_Table::$cache + $tables;
if (!is_array($database)) {
if (isset($tables[$database])) {
return $tables[$database];
} elseif (isset($tables[strtolower($database)])) {
// on windows with lower_case_table_names = 1
// MySQL returns
// with SHOW DATABASES or information_schema.SCHEMATA: `Test`
// but information_schema.TABLES gives `test`
// bug #1436171
// http://sf.net/support/tracker.php?aid=1436171
return $tables[strtolower($database)];
} else {
return $tables;
}
} else {
return $tables;
}
}
示例13: isset
*/
// BEGIN - Calc Table Space - staybyte - 9 June 2001
// loic1, 22 feb. 2002: updated with patch from
// Joshua Nye <josh at boxcarmedia.com> to get valid
// statistics whatever is the table type
if ($cfg['ShowStats']) {
if (empty($showtable)) {
$showtable = PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, true);
}
$nonisam = false;
$is_innodb = isset($showtable['Type']) && $showtable['Type'] == 'InnoDB';
if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
$nonisam = true;
}
// Gets some sizes
$mergetable = PMA_Table::isMerge($GLOBALS['db'], $GLOBALS['table']);
// this is to display for example 261.2 MiB instead of 268k KiB
$max_digits = 5;
$decimals = 1;
list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
if ($mergetable == false) {
list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
}
// InnoDB returns a huge value in Data_free, do not use it
if (!$is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
} else {
list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
}
list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
示例14: PMA_getForeigners
/**
* Gets all Relations to foreign tables for a given table or
* optionally a given column in a table
*
* @param string $db the name of the db to check for
* @param string $table the name of the table to check for
* @param string $column the name of the column to check for
* @param string $source the source for foreign key information
*
* @return array db,table,column
*
* @access public
*/
function PMA_getForeigners($db, $table, $column = '', $source = 'both')
{
$cfgRelation = PMA_getRelationsParam();
$foreign = array();
if ($cfgRelation['relwork'] && ($source == 'both' || $source == 'internal')) {
$rel_query = '
SELECT `master_field`,
`foreign_db`,
`foreign_table`,
`foreign_field`
FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' . PMA_Util::backquote($cfgRelation['relation']) . '
WHERE `master_db` = \'' . PMA_Util::sqlAddSlashes($db) . '\'
AND `master_table` = \'' . PMA_Util::sqlAddSlashes($table) . '\' ';
if (mb_strlen($column)) {
$rel_query .= ' AND `master_field` = ' . '\'' . PMA_Util::sqlAddSlashes($column) . '\'';
}
$foreign = $GLOBALS['dbi']->fetchResult($rel_query, 'master_field', null, $GLOBALS['controllink']);
}
if (($source == 'both' || $source == 'foreign') && mb_strlen($table)) {
$tableObj = new PMA_Table($table, $db);
$show_create_table = $tableObj->showCreate();
if ($show_create_table) {
$parser = new SqlParser\Parser($show_create_table);
/**
* @var CreateStatement $stmt
*/
$stmt = $parser->statements[0];
$foreign['foreign_keys_data'] = SqlParser\Utils\Table::getForeignKeys($stmt);
}
}
/**
* Emulating relations for some information_schema and data_dictionary tables
*/
$isInformationSchema = mb_strtolower($db) == 'information_schema';
$is_data_dictionary = PMA_DRIZZLE && mb_strtolower($db) == 'data_dictionary';
$isMysql = mb_strtolower($db) == 'mysql';
if (($isInformationSchema || $is_data_dictionary || $isMysql) && ($source == 'internal' || $source == 'both')) {
if ($isInformationSchema) {
$relations_key = 'information_schema_relations';
include_once './libraries/information_schema_relations.lib.php';
} else {
if ($is_data_dictionary) {
$relations_key = 'data_dictionary_relations';
include_once './libraries/data_dictionary_relations.lib.php';
} else {
$relations_key = 'mysql_relations';
include_once './libraries/mysql_relations.lib.php';
}
}
if (isset($GLOBALS[$relations_key][$table])) {
foreach ($GLOBALS[$relations_key][$table] as $field => $relations) {
if ((!mb_strlen($column) || $column == $field) && (!isset($foreign[$field]) || !mb_strlen($foreign[$field]))) {
$foreign[$field] = $relations;
}
}
}
}
return $foreign;
}
示例15: isset
if (empty($_REQUEST['target_db'])) {
$_REQUEST['target_db'] = $db;
}
/**
* A target table name has been sent to this script -> do the work
*/
if (PMA_isValid($_REQUEST['new_name'])) {
if ($db == $_REQUEST['target_db'] && $table == $_REQUEST['new_name']) {
if (isset($_REQUEST['submit_move'])) {
$message = PMA_Message::error(__('Can\'t move table to same one!'));
} else {
$message = PMA_Message::error(__('Can\'t copy table to same one!'));
}
$result = false;
} else {
$result = PMA_Table::moveCopy($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name'], $_REQUEST['what'], isset($_REQUEST['submit_move']), 'one_table');
if (isset($_REQUEST['submit_move'])) {
$message = PMA_Message::success(__('Table %s has been moved to %s.'));
} else {
$message = PMA_Message::success(__('Table %s has been copied to %s.'));
}
$old = PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table);
$message->addParam($old);
$new = PMA_Util::backquote($_REQUEST['target_db']) . '.' . PMA_Util::backquote($_REQUEST['new_name']);
$message->addParam($new);
/* Check: Work on new table or on old table? */
if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) {
$db = $_REQUEST['target_db'];
$table = $_REQUEST['new_name'];
}
$reload = 1;