本文整理汇总了PHP中PMA_getDbCollation函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_getDbCollation函数的具体用法?PHP PMA_getDbCollation怎么用?PHP PMA_getDbCollation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_getDbCollation函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetDbCollation
/**
* Test for PMA_getDbCollation
*
* @return void
* @test
*/
public function testGetDbCollation()
{
$GLOBALS['server'] = 1;
// test case for system schema
$this->assertEquals('utf8_general_ci', PMA_getDbCollation("information_schema"));
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['cfg']['DBG']['sql'] = false;
$this->assertEquals('utf8_general_ci', PMA_getDbCollation('pma_test'));
}
示例2: PMA_exportDBCreate
/**
* Outputs create database database
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
global $crlf;
if (isset($GLOBALS['drop_database'])) {
if (!PMA_exportOutputHandler('DROP DATABASE ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : $db) . ';' . $crlf)) {
return FALSE;
}
}
$create_query = 'CREATE DATABASE ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : $db);
if (PMA_MYSQL_INT_VERSION >= 40101) {
$collation = PMA_getDbCollation($db);
if (strpos($collation, '_')) {
$create_query .= ' DEFAULT CHARACTER SET ' . substr($collation, 0, strpos($collation, '_')) . ' COLLATE ' . $collation;
} else {
$create_query .= ' DEFAULT CHARACTER SET ' . $collation;
}
}
$create_query .= ';' . $crlf;
if (!PMA_exportOutputHandler($create_query)) {
return FALSE;
}
return PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
}
示例3: PMA_DBI_get_databases_full
//.........这里部分代码省略.........
}
$sql .= $sql_where_schema . '
GROUP BY s.SCHEMA_NAME
ORDER BY ' . $common_functions->backquote($sort_by) . ' ' . $sort_order . $limit;
} else {
$sql = 'SELECT
s.SCHEMA_NAME,
s.DEFAULT_COLLATION_NAME';
if ($force_stats) {
$sql .= ',
COUNT(t.TABLE_SCHEMA) AS SCHEMA_TABLES,
SUM(t.TABLE_ROWS) AS SCHEMA_TABLE_ROWS,
SUM(t.DATA_LENGTH) AS SCHEMA_DATA_LENGTH,
SUM(t.MAX_DATA_LENGTH) AS SCHEMA_MAX_DATA_LENGTH,
SUM(t.INDEX_LENGTH) AS SCHEMA_INDEX_LENGTH,
SUM(t.DATA_LENGTH + t.INDEX_LENGTH)
AS SCHEMA_LENGTH,
SUM(t.DATA_FREE) AS SCHEMA_DATA_FREE';
}
$sql .= '
FROM `information_schema`.SCHEMATA s';
if ($force_stats) {
$sql .= '
LEFT JOIN `information_schema`.TABLES t
ON BINARY t.TABLE_SCHEMA = BINARY s.SCHEMA_NAME';
}
$sql .= $sql_where_schema . '
GROUP BY BINARY s.SCHEMA_NAME
ORDER BY BINARY ' . $common_functions->backquote($sort_by) . ' ' . $sort_order . $limit;
}
$databases = PMA_DBI_fetch_result($sql, 'SCHEMA_NAME', null, $link);
$mysql_error = PMA_DBI_getError($link);
if (!count($databases) && $GLOBALS['errno']) {
$common_functions->mysqlDie($mysql_error, $sql);
}
// display only databases also in official database list
// f.e. to apply hide_db and only_db
$drops = array_diff(array_keys($databases), (array) $GLOBALS['pma']->databases);
if (count($drops)) {
foreach ($drops as $drop) {
unset($databases[$drop]);
}
unset($drop);
}
unset($sql_where_schema, $sql, $drops);
} else {
foreach ($GLOBALS['pma']->databases as $database_name) {
// MySQL forward compatibility
// so pma could use this array as if every server is of version >5.0
// todo : remove and check the rest of the code for usage,
// MySQL 5.0 or higher is required for current PMA version
$databases[$database_name]['SCHEMA_NAME'] = $database_name;
if ($force_stats) {
include_once './libraries/mysql_charsets.lib.php';
$databases[$database_name]['DEFAULT_COLLATION_NAME'] = PMA_getDbCollation($database_name);
// get additional info about tables
$databases[$database_name]['SCHEMA_TABLES'] = 0;
$databases[$database_name]['SCHEMA_TABLE_ROWS'] = 0;
$databases[$database_name]['SCHEMA_DATA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_INDEX_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_DATA_FREE'] = 0;
$res = PMA_DBI_query('SHOW TABLE STATUS FROM ' . $common_functions->backquote($database_name) . ';');
while ($row = PMA_DBI_fetch_assoc($res)) {
$databases[$database_name]['SCHEMA_TABLES']++;
$databases[$database_name]['SCHEMA_TABLE_ROWS'] += $row['Rows'];
$databases[$database_name]['SCHEMA_DATA_LENGTH'] += $row['Data_length'];
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] += $row['Max_data_length'];
$databases[$database_name]['SCHEMA_INDEX_LENGTH'] += $row['Index_length'];
// for InnoDB, this does not contain the number of
// overhead bytes but the total free space
if ('InnoDB' != $row['Engine']) {
$databases[$database_name]['SCHEMA_DATA_FREE'] += $row['Data_free'];
}
$databases[$database_name]['SCHEMA_LENGTH'] += $row['Data_length'] + $row['Index_length'];
}
PMA_DBI_free_result($res);
unset($res);
}
}
}
/**
* apply limit and order manually now
* (caused by older MySQL < 5 or $GLOBALS['cfg']['NaturalOrder'])
*/
if ($apply_limit_and_order_manual) {
$GLOBALS['callback_sort_order'] = $sort_order;
$GLOBALS['callback_sort_by'] = $sort_by;
usort($databases, 'PMA_usort_comparison_callback');
unset($GLOBALS['callback_sort_order'], $GLOBALS['callback_sort_by']);
/**
* now apply limit
*/
if ($limit_count) {
$databases = array_slice($databases, $limit_offset, $limit_count);
}
}
return $databases;
}
示例4: exportDBCreate
/**
* Outputs CREATE DATABASE statement
*
* @param string $db Database name
* @param string $export_type 'server', 'database', 'table'
* @param string $db_alias Aliases of db
*
* @return bool Whether it succeeded
*/
public function exportDBCreate($db, $export_type, $db_alias = '')
{
global $crlf;
if (empty($db_alias)) {
$db_alias = $db;
}
if (isset($GLOBALS['sql_compatibility'])) {
$compat = $GLOBALS['sql_compatibility'];
} else {
$compat = 'NONE';
}
if (isset($GLOBALS['sql_drop_database'])) {
if (!PMA_exportOutputHandler('DROP DATABASE ' . PMA_Util::backquoteCompat($db_alias, $compat, isset($GLOBALS['sql_backquotes'])) . ';' . $crlf)) {
return false;
}
}
if ($export_type == 'database' && !isset($GLOBALS['sql_create_database'])) {
return true;
}
$create_query = 'CREATE DATABASE IF NOT EXISTS ' . PMA_Util::backquoteCompat($db_alias, $compat, isset($GLOBALS['sql_backquotes']));
$collation = PMA_getDbCollation($db);
if (mb_strpos($collation, '_')) {
$create_query .= ' DEFAULT CHARACTER SET ' . mb_substr($collation, 0, mb_strpos($collation, '_')) . ' COLLATE ' . $collation;
} else {
$create_query .= ' DEFAULT CHARACTER SET ' . $collation;
}
$create_query .= ';' . $crlf;
if (!PMA_exportOutputHandler($create_query)) {
return false;
}
return $this->_exportUseStatement($db_alias, $compat);
}
示例5: PMA_setDbComment
* (must be done before displaying the menu tabs)
*/
if (isset($_REQUEST['comment'])) {
PMA_setDbComment($GLOBALS['db'], $_REQUEST['comment']);
}
require 'libraries/db_common.inc.php';
$url_query .= '&goto=db_operations.php';
// Gets the database structure
$sub_part = '_structure';
list($tables, $num_tables, $total_num_tables, $sub_part, $is_show_stats, $db_is_system_schema, $tooltip_truename, $tooltip_aliasname, $pos) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
echo "\n";
if (isset($message)) {
echo PMA\libraries\Util::getMessage($message, $sql_query);
unset($message);
}
$_REQUEST['db_collation'] = PMA_getDbCollation($GLOBALS['db']);
$is_information_schema = $GLOBALS['dbi']->isSystemSchema($GLOBALS['db']);
$response->addHTML('<div id="boxContainer" data-box-width="300">');
if (!$is_information_schema) {
if ($cfgRelation['commwork']) {
/**
* database comment
*/
$response->addHTML(PMA_getHtmlForDatabaseComment($GLOBALS['db']));
}
$response->addHTML('<div class="operations_half_width">');
$response->addHTML(PMA_getHtmlForCreateTable($db));
$response->addHTML('</div>');
/**
* rename database
*/
示例6: PMA_setDbComment
* (must be done before displaying the menu tabs)
*/
if (isset($_REQUEST['comment'])) {
PMA_setDbComment($db, $_REQUEST['comment']);
}
require 'libraries/db_common.inc.php';
$url_query .= '&goto=db_operations.php';
// Gets the database structure
$sub_part = '_structure';
require 'libraries/db_info.inc.php';
echo "\n";
if (isset($message)) {
echo PMA_Util::getMessage($message, $sql_query);
unset($message);
}
$_REQUEST['db_collation'] = PMA_getDbCollation($db);
$is_information_schema = $GLOBALS['dbi']->isSystemSchema($db);
$response->addHTML('<div id="boxContainer" data-box-width="300">');
if (!$is_information_schema) {
if ($cfgRelation['commwork']) {
/**
* database comment
*/
$response->addHTML(PMA_getHtmlForDatabaseComment($db));
}
$response->addHTML('<div class="operations_half_width">');
ob_start();
include 'libraries/display_create_table.lib.php';
$content = ob_get_contents();
ob_end_clean();
$response->addHTML($content);
示例7: indexAction
/**
* Index action
*
* @return void
*/
public function indexAction()
{
// Add/Remove favorite tables using Ajax request.
if ($GLOBALS['is_ajax_request'] && !empty($_REQUEST['favorite_table'])) {
$this->addRemoveFavoriteTablesAction();
return;
}
$this->response->getHeader()->getScripts()->addFiles(array('db_structure.js', 'tbl_change.js', 'jquery/jquery-ui-timepicker-addon.js'));
// Drops/deletes/etc. multiple tables if required
if (!empty($_POST['submit_mult']) && isset($_POST['selected_tbl']) || isset($_POST['mult_btn'])) {
$action = 'db_structure.php';
$err_url = 'db_structure.php' . PMA_URL_getCommon(array('db' => $this->db));
// see bug #2794840; in this case, code path is:
// db_structure.php -> libraries/mult_submits.inc.php -> sql.php
// -> db_structure.php and if we got an error on the multi submit,
// we must display it here and not call again mult_submits.inc.php
if (!isset($_POST['error']) || false === $_POST['error']) {
include 'libraries/mult_submits.inc.php';
}
if (empty($_POST['message'])) {
$_POST['message'] = PMA_Message::success();
}
}
$this->_url_query .= '&goto=db_structure.php';
// Gets the database structure
$sub_part = '_structure';
list($tables, $num_tables, $total_num_tables, $sub_part, $is_show_stats, $db_is_system_schema, $tooltip_truename, $tooltip_aliasname, $pos) = PMA_Util::getDbInfo($GLOBALS['db'], isset($sub_part) ? $sub_part : '');
$this->_tables = $tables;
// updating $tables seems enough for #11376, but updating other
// variables too in case they may cause some other problem.
$this->_num_tables = $num_tables;
$this->_pos = $pos;
$this->_db_is_system_schema = $db_is_system_schema;
$this->_total_num_tables = $total_num_tables;
$this->_is_show_stats = $is_show_stats;
// If there is an Ajax request for real row count of a table.
if ($GLOBALS['is_ajax_request'] && isset($_REQUEST['real_row_count']) && $_REQUEST['real_row_count'] == true) {
$this->handleRealRowCountRequestAction();
return;
}
if (!PMA_DRIZZLE) {
include_once 'libraries/replication.inc.php';
} else {
$GLOBALS['replication_info']['slave']['status'] = false;
}
PMA_PageSettings::showGroup('DbStructure');
$db_collation = PMA_getDbCollation($this->db);
$titles = PMA_Util::buildActionTitles();
// 1. No tables
if ($this->_num_tables == 0) {
$this->response->addHTML(PMA_message::notice(__('No tables found in database.')));
if (empty($db_is_system_schema)) {
$this->response->addHTML(PMA_getHtmlForCreateTable($this->db));
}
return;
}
// else
// 2. Shows table information
/**
* Displays the tables list
*/
$this->response->addHTML('<div id="tableslistcontainer">');
$_url_params = array('pos' => $this->_pos, 'db' => $this->db);
// Add the sort options if they exists
if (isset($_REQUEST['sort'])) {
$_url_params['sort'] = $_REQUEST['sort'];
}
if (isset($_REQUEST['sort_order'])) {
$_url_params['sort_order'] = $_REQUEST['sort_order'];
}
$this->response->addHTML(PMA_Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']));
// table form
$this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
$i = $sum_entries = 0;
$overhead_check = '';
$create_time_all = '';
$update_time_all = '';
$check_time_all = '';
$num_columns = $GLOBALS['cfg']['PropertiesNumColumns'] > 1 ? ceil($this->_num_tables / $GLOBALS['cfg']['PropertiesNumColumns']) + 1 : 0;
$row_count = 0;
$sum_size = (double) 0;
$overhead_size = (double) 0;
$hidden_fields = array();
$odd_row = true;
$overall_approx_rows = false;
// Instance of PMA_RecentFavoriteTable class.
$fav_instance = PMA_RecentFavoriteTable::getInstance('favorite');
foreach ($this->_tables as $keyname => $current_table) {
// Get valid statistics whatever is the table type
$drop_query = '';
$drop_message = '';
$already_favorite = false;
$overhead = '';
$table_is_view = false;
$table_encoded = urlencode($current_table['TABLE_NAME']);
//.........这里部分代码省略.........
开发者ID:TheBlackBloodyUnicorn,项目名称:pico_wanderblog,代码行数:101,代码来源:DatabaseStructureController.class.php
示例8: displayTableList
//.........这里部分代码省略.........
$table_encoded = urlencode($current_table['TABLE_NAME']);
// Sets parameters for links
$tbl_url_query = $this->_url_query . '&table=' . $table_encoded;
// do not list the previous table's size info for a view
list($current_table, $formatted_size, $unit, $formatted_overhead, $overhead_unit, $overhead_size, $table_is_view, $sum_size) = $this->getStuffForEngineTypeTable($current_table, $sum_size, $overhead_size);
$curTable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME']);
if (!$curTable->isMerge()) {
$sum_entries += $current_table['TABLE_ROWS'];
}
if (isset($current_table['Collation'])) {
$collation = '<dfn title="' . PMA_getCollationDescr($current_table['Collation']) . '">' . $current_table['Collation'] . '</dfn>';
} else {
$collation = '---';
}
if ($this->_is_show_stats) {
if ($formatted_overhead != '') {
$overhead = '<a href="tbl_structure.php' . $tbl_url_query . '#showusage">' . '<span>' . $formatted_overhead . '</span> ' . '<span class="unit">' . $overhead_unit . '</span>' . '</a>' . "\n";
$overhead_check .= "markAllRows('row_tbl_" . ($i + 1) . "');";
} else {
$overhead = '-';
}
}
// end if
$showtable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME'])->getStatusInfo(null, true);
if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
$create_time = isset($showtable['Create_time']) ? $showtable['Create_time'] : '';
if ($create_time && (!$create_time_all || $create_time < $create_time_all)) {
$create_time_all = $create_time;
}
}
if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
// $showtable might already be set from ShowDbStructureCreation,
// see above
$update_time = isset($showtable['Update_time']) ? $showtable['Update_time'] : '';
if ($update_time && (!$update_time_all || $update_time < $update_time_all)) {
$update_time_all = $update_time;
}
}
if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
// $showtable might already be set from ShowDbStructureCreation,
// see above
$check_time = isset($showtable['Check_time']) ? $showtable['Check_time'] : '';
if ($check_time && (!$check_time_all || $check_time < $check_time_all)) {
$check_time_all = $check_time;
}
}
$truename = htmlspecialchars(!empty($tooltip_truename) && isset($tooltip_truename[$current_table['TABLE_NAME']]) ? $tooltip_truename[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']);
$truename = str_replace(' ', ' ', $truename);
$i++;
$row_count++;
if ($table_is_view) {
$hidden_fields[] = '<input type="hidden" name="views[]" value="' . htmlspecialchars($current_table['TABLE_NAME']) . '" />';
}
/*
* Always activate links for Browse, Search and Empty, even if
* the icons are greyed, because
* 1. for views, we don't know the number of rows at this point
* 2. for tables, another source could have populated them since the
* page was generated
*
* I could have used the PHP ternary conditional operator but I find
* the code easier to read without this operator.
*/
$may_have_rows = $current_table['TABLE_ROWS'] > 0 || $table_is_view;
$titles = Util::buildActionTitles();
$browse_table = Template::get('database/structure/browse_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Browse'] : $titles['NoBrowse']));
$search_table = Template::get('database/structure/search_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Search'] : $titles['NoSearch']));
$browse_table_label = Template::get('database/structure/browse_table_label')->render(array('tbl_url_query' => $tbl_url_query, 'title' => htmlspecialchars($current_table['TABLE_COMMENT']), 'truename' => $truename));
$empty_table = '';
if (!$this->_db_is_system_schema) {
$empty_table = ' ';
if (!$table_is_view) {
$empty_table = Template::get('database/structure/empty_table')->render(array('tbl_url_query' => $tbl_url_query, 'sql_query' => urlencode('TRUNCATE ' . Util::backquote($current_table['TABLE_NAME'])), 'message_to_show' => urlencode(sprintf(__('Table %s has been emptied.'), htmlspecialchars($current_table['TABLE_NAME']))), 'title' => $may_have_rows ? $titles['Empty'] : $titles['NoEmpty']));
}
$drop_query = sprintf('DROP %s %s', $table_is_view || $current_table['ENGINE'] == null ? 'VIEW' : 'TABLE', Util::backquote($current_table['TABLE_NAME']));
$drop_message = sprintf($table_is_view || $current_table['ENGINE'] == null ? __('View %s has been dropped.') : __('Table %s has been dropped.'), str_replace(' ', ' ', htmlspecialchars($current_table['TABLE_NAME'])));
}
if ($num_columns > 0 && $this->_num_tables > $num_columns && $row_count % $num_columns == 0) {
$row_count = 1;
$odd_row = true;
$this->response->addHTML('</tr></tbody></table></form>');
$this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
}
list($approx_rows, $show_superscript) = $this->isRowCountApproximated($current_table, $table_is_view);
list($do, $ignored) = $this->getReplicationStatus($truename);
$this->response->addHTML(Template::get('database/structure/structure_table_row')->render(array('db' => $this->db, 'curr' => $i, 'odd_row' => $odd_row, 'table_is_view' => $table_is_view, 'current_table' => $current_table, 'browse_table_label' => $browse_table_label, 'tracking_icon' => $this->getTrackingIcon($truename), 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'browse_table' => $browse_table, 'tbl_url_query' => $tbl_url_query, 'search_table' => $search_table, 'db_is_system_schema' => $this->_db_is_system_schema, 'titles' => $titles, 'empty_table' => $empty_table, 'drop_query' => $drop_query, 'drop_message' => $drop_message, 'collation' => $collation, 'formatted_size' => $formatted_size, 'unit' => $unit, 'overhead' => $overhead, 'create_time' => isset($create_time) ? $create_time : '', 'update_time' => isset($update_time) ? $update_time : '', 'check_time' => isset($check_time) ? $check_time : '', 'is_show_stats' => $this->_is_show_stats, 'ignored' => $ignored, 'do' => $do, 'colspan_for_structure' => $GLOBALS['colspan_for_structure'], 'approx_rows' => $approx_rows, 'show_superscript' => $show_superscript, 'already_favorite' => $this->checkFavoriteTable($current_table['TABLE_NAME']))));
$odd_row = !$odd_row;
$overall_approx_rows = $overall_approx_rows || $approx_rows;
}
// end foreach
$this->response->addHTML('</tbody>');
$db_collation = PMA_getDbCollation($this->db);
// Show Summary
$this->response->addHTML(Template::get('database/structure/body_for_table_summary')->render(array('num_tables' => $this->_num_tables, 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'db_is_system_schema' => $this->_db_is_system_schema, 'sum_entries' => $sum_entries, 'db_collation' => $db_collation, 'is_show_stats' => $this->_is_show_stats, 'sum_size' => $sum_size, 'overhead_size' => $overhead_size, 'create_time_all' => $create_time_all, 'update_time_all' => $update_time_all, 'check_time_all' => $check_time_all, 'approx_rows' => $overall_approx_rows)));
$this->response->addHTML('</table>');
//check all
$this->response->addHTML(Template::get('database/structure/check_all_tables')->render(array('pmaThemeImage' => $GLOBALS['pmaThemeImage'], 'text_dir' => $GLOBALS['text_dir'], 'overhead_check' => $overhead_check, 'db_is_system_schema' => $this->_db_is_system_schema, 'hidden_fields' => $hidden_fields)));
$this->response->addHTML('</form>');
//end of form
}
示例9: convert_one_db
function convert_one_db($db)
{
global $alterdatabasecharset;
global $altertablecharset;
global $charset;
global $collate;
global $printonly;
global $db_handle;
$db_cha = PMA_getDbCollation($db);
if (substr($db_cha[0], 0, 4) == 'utf8') {
// This doesn't work for me, but isn't a big deal, as the table
// check below works
echo "Skipping utf8 database '{$db}'\n";
return;
}
sql_command("USE {$db}", $db_handle);
$rs = sql_query("SHOW TABLES", $db_handle);
if (!$rs) {
echo "\n\n" . sql_error($db_handle) . "\n\n";
} else {
for ($i = 0; $data = sql_row($rs, $i, $db_handle); $i++) {
echo "Converting '{$data['0']}' table...\n";
$rs1 = sql_query("show FULL columns from {$data['0']}", $db_handle);
if (!$rs1) {
echo "\n\n" . sql_error($db_handle) . "\n\n";
} else {
for ($j = 0; $data1 = sql_row_keyed($rs1, $j, $db_handle); $j++) {
if (in_array(array_shift(split("\\(", $data1['Type'], 2)), array('char', 'varchar', 'tinytext', 'text', 'mediumtext', 'longtext', 'enum', 'set'))) {
if (substr($data1['Collation'], 0, 4) != 'utf8') {
$sq = "ALTER TABLE `{$data['0']}` CHANGE `" . $data1['Field'] . '` `' . $data1['Field'] . '` ' . $data1['Type'] . ' CHARACTER SET binary ' . ($data1['Default'] == '' ? '' : ($data1['Default'] == 'NULL' ? ' DEFAULT NULL' : ' DEFAULT \'' . addslashes($data1['Default']) . '\'')) . ($data1['Null'] == 'YES' ? ' NULL ' : ' NOT NULL');
if (!$printonly && !sql_query($sq, $db_handle)) {
echo "\n\n" . $sq . "\n" . sql_error($db_handle) . "\n\n";
} else {
if ($printonly) {
echo $sq . "\n";
}
$sq = "ALTER TABLE `{$data['0']}` CHANGE `" . $data1['Field'] . '` `' . $data1['Field'] . '` ' . $data1['Type'] . " CHARACTER SET {$charset} " . ($collate == '' ? '' : "COLLATE {$collate}") . ($data1['Default'] == '' ? '' : ($data1['Default'] == 'NULL' ? ' DEFAULT NULL' : ' DEFAULT \'' . addslashes($data1['Default']) . '\'')) . ($data1['Null'] == 'YES' ? ' NULL ' : ' NOT NULL') . ($data1['Comment'] == '' ? '' : ' COMMENT \'' . addslashes($data1['Comment']) . '\'');
if (!$printonly && !sql_query($sq, $db_handle)) {
echo "\n\n" . $sq . "\n" . sql_error($db_handle) . "\n\n";
} else {
if ($printonly) {
echo $sq . "\n";
}
}
}
// end of if (!$printonly)
}
// end of if (substr)
}
// end of if (in_array)
}
// end of inner for
}
// end of if ($rs1)
if ($altertablecharset) {
$sq = 'ALTER TABLE `' . $data[0] . "` " . "DEFAULT CHARACTER SET {$charset} " . ($collate == '' ? '' : "COLLATE {$collate}");
if ($printonly) {
echo $sq . "\n";
} else {
if (!sql_query($sq, $db_handle)) {
echo "\n\n" . $sq . "\n" . sql_error($db_handle) . "\n\n";
}
}
}
// end of if ($altertablecharset)
print "done.<br>\n";
}
// end of outer for
}
// end of if (!$rs)
if ($alterdatabasecharset) {
$sq = 'ALTER DATABASE `' . $db . "` " . "DEFAULT CHARACTER SET {$charset} " . ($collate == '' ? '' : "COLLATE {$collate}");
if ($printonly) {
echo $sq . "\n";
} else {
if (!sql_query($sq, $db_handle)) {
echo "\n\n" . $sq . "\n" . sql_error($db_handle) . "\n\n";
}
}
}
// end of if ($alterdatabasecharset)
}
示例10: testGetDbCollation
/**
* Test for PMA_getDbCollation
*
* @return void
* @test
*/
public function testGetDbCollation()
{
if (!PMA_HAS_RUNKIT) {
$this->markTestSkipped('Cannot redefine constant - missing runkit extension');
} else {
$GLOBALS['server'] = 1;
// test case for system schema
$this->assertEquals('utf8_general_ci', PMA_getDbCollation("information_schema"));
$restoreDrizzle = '';
// test case with no pma drizzle
if (defined('PMA_DRIZZLE')) {
$restoreDrizzle = PMA_DRIZZLE;
runkit_constant_redefine('PMA_DRIZZLE', false);
} else {
$restoreDrizzle = 'PMA_TEST_CONSTANT_REMOVE';
define('PMA_DRIZZLE', false);
}
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['cfg']['DBG']['sql'] = false;
$this->assertEquals('utf8_general_ci', PMA_getDbCollation('pma_test'));
// test case with pma drizzle as true
runkit_constant_redefine('PMA_DRIZZLE', true);
$this->assertEquals('utf8_general_ci_pma_drizzle', PMA_getDbCollation('pma_test'));
$GLOBALS['cfg']['Server']['DisableIS'] = true;
$GLOBALS['db'] = 'pma_test2';
$this->assertEquals('bar', PMA_getDbCollation('pma_test'));
$this->assertNotEquals('pma_test', $GLOBALS['dummy_db']);
if ($restoreDrizzle === 'PMA_TEST_CONSTANT_REMOVE') {
runkit_constant_remove('PMA_DRIZZLE');
} else {
runkit_constant_redefine('PMA_DRIZZLE', $restoreDrizzle);
}
}
}
示例11: PMA_DBI_get_databases_full
/**
* returns array with databases containing extended infos about them
*
* @param string $databases database
* @param boolean $force_stats retrieve stats also for MySQL < 5
* @param resource $link mysql link
* @param string $sort_by collumn to order by
* @param string $sort_order ASC or DESC
* @param integer $limit_offset starting offset for LIMIT
* @param bool|int $limit_count row count for LIMIT or true for $GLOBALS['cfg']['MaxDbList']
* @return array $databases
*/
function PMA_DBI_get_databases_full($database = null, $force_stats = false, $link = null, $sort_by = 'SCHEMA_NAME', $sort_order = 'ASC', $limit_offset = 0, $limit_count = false)
{
$sort_order = strtoupper($sort_order);
if (true === $limit_count) {
$limit_count = $GLOBALS['cfg']['MaxDbList'];
}
// initialize to avoid errors when there are no databases
$databases = array();
$apply_limit_and_order_manual = true;
if (PMA_MYSQL_INT_VERSION >= 50002) {
/**
* if $GLOBALS['cfg']['NaturalOrder'] is enabled, we cannot use LIMIT
* cause MySQL does not support natural ordering, we have to do it afterward
*/
if ($GLOBALS['cfg']['NaturalOrder']) {
$limit = '';
} else {
if ($limit_count) {
$limit = ' LIMIT ' . $limit_count . ' OFFSET ' . $limit_offset;
}
$apply_limit_and_order_manual = false;
}
// get table information from information_schema
if ($database) {
$sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \'' . addslashes($database) . '\'';
} else {
$sql_where_schema = '';
}
// for PMA bc:
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
$sql = '
SELECT `information_schema`.`SCHEMATA`.*';
if ($force_stats) {
$sql .= ',
COUNT(`information_schema`.`TABLES`.`TABLE_SCHEMA`)
AS `SCHEMA_TABLES`,
SUM(`information_schema`.`TABLES`.`TABLE_ROWS`)
AS `SCHEMA_TABLE_ROWS`,
SUM(`information_schema`.`TABLES`.`DATA_LENGTH`)
AS `SCHEMA_DATA_LENGTH`,
SUM(`information_schema`.`TABLES`.`MAX_DATA_LENGTH`)
AS `SCHEMA_MAX_DATA_LENGTH`,
SUM(`information_schema`.`TABLES`.`INDEX_LENGTH`)
AS `SCHEMA_INDEX_LENGTH`,
SUM(`information_schema`.`TABLES`.`DATA_LENGTH`
+ `information_schema`.`TABLES`.`INDEX_LENGTH`)
AS `SCHEMA_LENGTH`,
SUM(`information_schema`.`TABLES`.`DATA_FREE`)
AS `SCHEMA_DATA_FREE`';
}
$sql .= '
FROM `information_schema`.`SCHEMATA`';
if ($force_stats) {
$sql .= '
LEFT JOIN `information_schema`.`TABLES`
ON `information_schema`.`TABLES`.`TABLE_SCHEMA`
= `information_schema`.`SCHEMATA`.`SCHEMA_NAME`';
}
$sql .= '
' . $sql_where_schema . '
GROUP BY `information_schema`.`SCHEMATA`.`SCHEMA_NAME`
ORDER BY ' . PMA_backquote($sort_by) . ' ' . $sort_order . $limit;
$databases = PMA_DBI_fetch_result($sql, 'SCHEMA_NAME', null, $link);
unset($sql_where_schema, $sql);
} else {
foreach (PMA_DBI_get_dblist($link) as $database_name) {
// MySQL forward compatibility
// so pma could use this array as if every server is of version >5.0
$databases[$database_name]['SCHEMA_NAME'] = $database_name;
if ($force_stats) {
require_once 'mysql_charsets.lib.php';
$databases[$database_name]['DEFAULT_COLLATION_NAME'] = PMA_getDbCollation($database_name);
// get additonal info about tables
$databases[$database_name]['SCHEMA_TABLES'] = 0;
$databases[$database_name]['SCHEMA_TABLE_ROWS'] = 0;
$databases[$database_name]['SCHEMA_DATA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_INDEX_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_DATA_FREE'] = 0;
$res = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($database_name) . ';');
while ($row = PMA_DBI_fetch_assoc($res)) {
$databases[$database_name]['SCHEMA_TABLES']++;
$databases[$database_name]['SCHEMA_TABLE_ROWS'] += $row['Rows'];
$databases[$database_name]['SCHEMA_DATA_LENGTH'] += $row['Data_length'];
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] += $row['Max_data_length'];
$databases[$database_name]['SCHEMA_INDEX_LENGTH'] += $row['Index_length'];
$databases[$database_name]['SCHEMA_DATA_FREE'] += $row['Data_free'];
//.........这里部分代码省略.........
示例12: PMA_DBI_get_databases_full
/**
* returns array with databases containing extended infos about them
*
* @param string $databases database
* @param boolean $force_stats retrieve stats also for MySQL < 5
* @param resource $link mysql link
* @return array $databases
*/
function PMA_DBI_get_databases_full($database = NULL, $force_stats = false, $link = NULL)
{
// initialize to avoid errors when there are no databases
$databases = array();
if (PMA_MYSQL_INT_VERSION >= 50002) {
// get table information from information_schema
if ($database) {
$sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \'' . addslashes($database) . '\'';
} else {
$sql_where_schema = '';
}
// for PMA bc:
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
$sql = '
SELECT `information_schema`.`SCHEMATA`.*,
COUNT(`information_schema`.`TABLES`.`TABLE_SCHEMA`)
AS `SCHEMA_TABLES`,
SUM(`information_schema`.`TABLES`.`TABLE_ROWS`)
AS `SCHEMA_TABLE_ROWS`,
SUM(`information_schema`.`TABLES`.`DATA_LENGTH`)
AS `SCHEMA_DATA_LENGTH`,
SUM(`information_schema`.`TABLES`.`MAX_DATA_LENGTH`)
AS `SCHEMA_MAX_DATA_LENGTH`,
SUM(`information_schema`.`TABLES`.`INDEX_LENGTH`)
AS `SCHEMA_INDEX_LENGTH`,
SUM(`information_schema`.`TABLES`.`DATA_LENGTH`
+ `information_schema`.`TABLES`.`INDEX_LENGTH`)
AS `SCHEMA_LENGTH`,
SUM(`information_schema`.`TABLES`.`DATA_FREE`)
AS `SCHEMA_DATA_FREE`
FROM `information_schema`.`SCHEMATA`
LEFT JOIN `information_schema`.`TABLES`
ON `information_schema`.`TABLES`.`TABLE_SCHEMA`
= `information_schema`.`SCHEMATA`.`SCHEMA_NAME`
' . $sql_where_schema . '
GROUP BY `information_schema`.`SCHEMATA`.`SCHEMA_NAME`';
$databases = PMA_DBI_fetch_result($sql, 'SCHEMA_NAME', NULL, $link);
unset($sql_where_schema, $sql);
} else {
foreach (PMA_DBI_get_dblist($link) as $database_name) {
// MySQL forward compatibility
// so pma could use this array as if every server is of version >5.0
$databases[$database_name]['SCHEMA_NAME'] = $database_name;
if ($force_stats) {
require_once 'mysql_charsets.lib.php';
$databases[$database_name]['DEFAULT_COLLATION_NAME'] = PMA_getDbCollation($database_name);
// get additonal info about tables
$databases[$database_name]['SCHEMA_TABLES'] = 0;
$databases[$database_name]['SCHEMA_TABLE_ROWS'] = 0;
$databases[$database_name]['SCHEMA_DATA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_INDEX_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_DATA_FREE'] = 0;
$res = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($database_name) . ';');
while ($row = PMA_DBI_fetch_assoc($res)) {
$databases[$database_name]['SCHEMA_TABLES']++;
$databases[$database_name]['SCHEMA_TABLE_ROWS'] += $row['Rows'];
$databases[$database_name]['SCHEMA_DATA_LENGTH'] += $row['Data_length'];
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] += $row['Max_data_length'];
$databases[$database_name]['SCHEMA_INDEX_LENGTH'] += $row['Index_length'];
$databases[$database_name]['SCHEMA_DATA_FREE'] += $row['Data_free'];
$databases[$database_name]['SCHEMA_LENGTH'] += $row['Data_length'] + $row['Index_length'];
}
PMA_DBI_free_result($res);
unset($res);
}
}
}
if ($GLOBALS['cfg']['NaturalOrder']) {
uksort($databases, 'strnatcasecmp');
}
return $databases;
}
示例13: PMA_exportDBCreate
/**
* Outputs CREATE DATABASE database
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
global $crlf;
if (isset($GLOBALS['sql_drop_database'])) {
if (!PMA_exportOutputHandler('DROP DATABASE ' . (isset($GLOBALS['sql_backquotes']) ? PMA_backquote($db) : $db) . ';' . $crlf)) {
return FALSE;
}
}
$create_query = 'CREATE DATABASE ' . (isset($GLOBALS['sql_backquotes']) ? PMA_backquote($db) : $db);
$collation = PMA_getDbCollation($db);
if (strpos($collation, '_')) {
$create_query .= ' DEFAULT CHARACTER SET ' . substr($collation, 0, strpos($collation, '_')) . ' COLLATE ' . $collation;
} else {
$create_query .= ' DEFAULT CHARACTER SET ' . $collation;
}
$create_query .= ';' . $crlf;
if (!PMA_exportOutputHandler($create_query)) {
return FALSE;
}
if (isset($GLOBALS['sql_backquotes']) && isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] == 'NONE') {
$result = PMA_exportOutputHandler('USE ' . PMA_backquote($db) . ';' . $crlf);
} else {
$result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
}
if ($result && isset($GLOBALS['sql_structure']) && isset($GLOBALS['sql_procedure_function'])) {
$text = '';
$delimiter = '$$';
$procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
$function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
if ($procedure_names || $function_names) {
$text .= $crlf . 'DELIMITER ' . $delimiter . $crlf;
}
if ($procedure_names) {
$text .= PMA_exportComment() . PMA_exportComment($GLOBALS['strProcedures']) . PMA_exportComment();
foreach ($procedure_names as $procedure_name) {
if (!empty($GLOBALS['sql_drop_table'])) {
$text .= 'DROP PROCEDURE IF EXISTS ' . PMA_backquote($procedure_name) . $delimiter . $crlf;
}
$text .= PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf;
}
}
if ($function_names) {
$text .= PMA_exportComment() . PMA_exportComment($GLOBALS['strFunctions']) . PMA_exportComment();
foreach ($function_names as $function_name) {
if (!empty($GLOBALS['sql_drop_table'])) {
$text .= 'DROP FUNCTION IF EXISTS ' . PMA_backquote($function_name) . $delimiter . $crlf;
}
$text .= PMA_DBI_get_definition($db, 'FUNCTION', $function_name) . $delimiter . $crlf . $crlf;
}
}
if ($procedure_names || $function_names) {
$text .= 'DELIMITER ;' . $crlf;
}
if (!empty($text)) {
$result = PMA_exportOutputHandler($text);
}
}
return $result;
}
示例14: indexAction
/**
* Index action
*
* @return void
*/
public function indexAction()
{
// Database structure
if ($this->_type == 'db') {
// Add/Remove favorite tables using Ajax request.
if ($GLOBALS['is_ajax_request'] && !empty($_REQUEST['favorite_table'])) {
$this->addRemoveFavoriteTables();
return;
}
$this->response->getHeader()->getScripts()->addFiles(array('db_structure.js', 'tbl_change.js', 'jquery/jquery-ui-timepicker-addon.js'));
// Drops/deletes/etc. multiple tables if required
if (!empty($_POST['submit_mult']) && isset($_POST['selected_tbl']) || isset($_POST['mult_btn'])) {
$action = 'db_structure.php';
$err_url = 'db_structure.php' . PMA_URL_getCommon(array('db' => $this->_db));
// see bug #2794840; in this case, code path is:
// db_structure.php -> libraries/mult_submits.inc.php -> sql.php
// -> db_structure.php and if we got an error on the multi submit,
// we must display it here and not call again mult_submits.inc.php
if (!isset($_POST['error']) || false === $_POST['error']) {
include 'libraries/mult_submits.inc.php';
}
if (empty($_POST['message'])) {
$_POST['message'] = PMA_Message::success();
}
}
$this->_url_query .= '&goto=db_structure.php';
// Gets the database structure
$sub_part = '_structure';
// If there is an Ajax request for real row count of a table.
if ($GLOBALS['is_ajax_request'] && isset($_REQUEST['real_row_count']) && $_REQUEST['real_row_count'] == true) {
$this->handleRealRowCountRequestAction();
return;
}
if (!PMA_DRIZZLE) {
include_once 'libraries/replication.inc.php';
} else {
$GLOBALS['replication_info']['slave']['status'] = false;
}
PMA_PageSettings::showGroup('DbStructure');
$db_collation = PMA_getDbCollation($this->_db);
$titles = PMA_Util::buildActionTitles();
// 1. No tables
if ($this->_num_tables == 0) {
$this->response->addHTML(PMA_message::notice(__('No tables found in database.')));
if (empty($db_is_system_schema)) {
$this->response->addHTML(PMA_getHtmlForCreateTable($this->_db));
}
return;
}
// else
// 2. Shows table information
/**
* Displays the tables list
*/
$this->response->addHTML('<div id="tableslistcontainer">');
$_url_params = array('pos' => $this->_pos, 'db' => $this->_db);
// Add the sort options if they exists
if (isset($_REQUEST['sort'])) {
$_url_params['sort'] = $_REQUEST['sort'];
}
if (isset($_REQUEST['sort_order'])) {
$_url_params['sort_order'] = $_REQUEST['sort_order'];
}
$this->response->addHTML(PMA_Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']));
// table form
$this->response->addHTML(Template::get('structure/table_header')->render(array('db' => $this->_db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
$i = $sum_entries = 0;
$overhead_check = '';
$create_time_all = '';
$update_time_all = '';
$check_time_all = '';
$num_columns = $GLOBALS['cfg']['PropertiesNumColumns'] > 1 ? ceil($this->_num_tables / $GLOBALS['cfg']['PropertiesNumColumns']) + 1 : 0;
$row_count = 0;
$sum_size = (double) 0;
$overhead_size = (double) 0;
$hidden_fields = array();
$odd_row = true;
$overall_approx_rows = false;
// Instance of PMA_RecentFavoriteTable class.
$fav_instance = PMA_RecentFavoriteTable::getInstance('favorite');
foreach ($this->_tables as $keyname => $current_table) {
// Get valid statistics whatever is the table type
$drop_query = '';
$drop_message = '';
$already_favorite = false;
$overhead = '';
$table_is_view = false;
$table_encoded = urlencode($current_table['TABLE_NAME']);
// Sets parameters for links
$tbl_url_query = $this->_url_query . '&table=' . $table_encoded;
// do not list the previous table's size info for a view
list($current_table, $formatted_size, $unit, $formatted_overhead, $overhead_unit, $overhead_size, $table_is_view, $sum_size) = $this->getStuffForEngineTypeTable($current_table, $this->_db_is_system_schema, $this->_is_show_stats, $sum_size, $overhead_size);
if (!$this->dbi->getTable($this->_db, $current_table['TABLE_NAME'])->isMerge()) {
$sum_entries += $current_table['TABLE_ROWS'];
}
//.........这里部分代码省略.........
示例15: PMA_DBI_get_databases_full
/**
* returns array with databases containing extended infos about them
*
* @todo move into PMA_List_Database?
* @param string $databases database
* @param boolean $force_stats retrieve stats also for MySQL < 5
* @param resource $link mysql link
* @param string $sort_by column to order by
* @param string $sort_order ASC or DESC
* @param integer $limit_offset starting offset for LIMIT
* @param bool|int $limit_count row count for LIMIT or true for $GLOBALS['cfg']['MaxDbList']
* @return array $databases
*/
function PMA_DBI_get_databases_full($database = null, $force_stats = false, $link = null, $sort_by = 'SCHEMA_NAME', $sort_order = 'ASC', $limit_offset = 0, $limit_count = false)
{
$sort_order = strtoupper($sort_order);
if (true === $limit_count) {
$limit_count = $GLOBALS['cfg']['MaxDbList'];
}
// initialize to avoid errors when there are no databases
$databases = array();
$apply_limit_and_order_manual = true;
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
/**
* if $GLOBALS['cfg']['NaturalOrder'] is enabled, we cannot use LIMIT
* cause MySQL does not support natural ordering, we have to do it afterward
*/
if ($GLOBALS['cfg']['NaturalOrder']) {
$limit = '';
} else {
if ($limit_count) {
$limit = ' LIMIT ' . $limit_count . ' OFFSET ' . $limit_offset;
}
$apply_limit_and_order_manual = false;
}
// get table information from information_schema
if ($database) {
$sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \'' . addslashes($database) . '\'';
} else {
$sql_where_schema = '';
}
// for PMA bc:
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
$sql = '
SELECT `information_schema`.`SCHEMATA`.*';
if ($force_stats) {
$sql .= ',
COUNT(`information_schema`.`TABLES`.`TABLE_SCHEMA`)
AS `SCHEMA_TABLES`,
SUM(`information_schema`.`TABLES`.`TABLE_ROWS`)
AS `SCHEMA_TABLE_ROWS`,
SUM(`information_schema`.`TABLES`.`DATA_LENGTH`)
AS `SCHEMA_DATA_LENGTH`,
SUM(`information_schema`.`TABLES`.`MAX_DATA_LENGTH`)
AS `SCHEMA_MAX_DATA_LENGTH`,
SUM(`information_schema`.`TABLES`.`INDEX_LENGTH`)
AS `SCHEMA_INDEX_LENGTH`,
SUM(`information_schema`.`TABLES`.`DATA_LENGTH`
+ `information_schema`.`TABLES`.`INDEX_LENGTH`)
AS `SCHEMA_LENGTH`,
SUM(`information_schema`.`TABLES`.`DATA_FREE`)
AS `SCHEMA_DATA_FREE`';
}
$sql .= '
FROM `information_schema`.`SCHEMATA`';
if ($force_stats) {
$sql .= '
LEFT JOIN `information_schema`.`TABLES`
ON BINARY `information_schema`.`TABLES`.`TABLE_SCHEMA`
= BINARY `information_schema`.`SCHEMATA`.`SCHEMA_NAME`';
}
$sql .= '
' . $sql_where_schema . '
GROUP BY BINARY `information_schema`.`SCHEMATA`.`SCHEMA_NAME`
ORDER BY BINARY ' . PMA_backquote($sort_by) . ' ' . $sort_order . $limit;
$databases = PMA_DBI_fetch_result($sql, 'SCHEMA_NAME', null, $link);
$mysql_error = PMA_DBI_getError($link);
if (!count($databases) && $GLOBALS['errno']) {
PMA_mysqlDie($mysql_error, $sql);
}
// display only databases also in official database list
// f.e. to apply hide_db and only_db
$drops = array_diff(array_keys($databases), (array) $GLOBALS['pma']->databases);
if (count($drops)) {
foreach ($drops as $drop) {
unset($databases[$drop]);
}
unset($drop);
}
unset($sql_where_schema, $sql, $drops);
} else {
foreach ($GLOBALS['pma']->databases as $database_name) {
// MySQL forward compatibility
// so pma could use this array as if every server is of version >5.0
$databases[$database_name]['SCHEMA_NAME'] = $database_name;
if ($force_stats) {
require_once './libraries/mysql_charsets.lib.php';
$databases[$database_name]['DEFAULT_COLLATION_NAME'] = PMA_getDbCollation($database_name);
// get additional info about tables
$databases[$database_name]['SCHEMA_TABLES'] = 0;
//.........这里部分代码省略.........