translation update
[phpmyadmin/last10db.git] / libraries / db_details_db_info.inc.php
blob32cd056a477197702e610455026cc41c990f20ef
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 // Check parameters
8 require_once('./libraries/common.lib.php');
10 PMA_checkParameters(array('db'));
12 if ( PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema' ) {
13 $cfg['ShowStats'] = false;
14 $db_is_information_schema = true;
15 } else {
16 $db_is_information_schema = false;
19 function fillTooltip( &$tooltip_truename, &$tooltip_aliasname, &$tmp ) {
20 $tooltip_truename[$tmp['Name']] = ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] != 'nested' ? (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name']) : $tmp['Name']);
21 $tooltip_aliasname[$tmp['Name']] = ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] != 'nested' ? $tmp['Name'] : (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name']));
22 if (isset($tmp['Create_time']) && !empty($tmp['Create_time'])) {
23 $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatCreateTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Create_time']));
26 if (isset($tmp['Update_time']) && !empty($tmp['Update_time'])) {
27 $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Update_time']));
30 if (isset($tmp['Check_time']) && !empty($tmp['Check_time'])) {
31 $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Check_time']));
34 return true;
37 /**
38 * Gets the list of the table in the current db and informations about these
39 * tables if possible
41 // staybyte: speedup view on locked tables - 11 June 2001
42 $tables = array();
44 // When used in Nested table group mode, only show tables matching the given groupname
45 if (!empty($tbl_group) && !$cfg['ShowTooltipAliasTB']) {
46 $tbl_group_sql = ' LIKE "' . PMA_escape_mysql_wildcards( $tbl_group ) . '%"';
47 } else {
48 $tbl_group_sql = '';
51 if ( $cfg['ShowTooltip'] ) {
52 $tooltip_truename = array();
53 $tooltip_aliasname = array();
56 // Special speedup for newer MySQL Versions (in 4.0 format changed)
57 if ( true === $cfg['SkipLockedTables'] ) {
58 $db_info_result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
60 // Blending out tables in use
61 if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
62 while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
63 // if in use memorize tablename
64 if (preg_match('@in_use=[1-9]+@i', $tmp[1])) {
65 $sot_cache[$tmp[0]] = TRUE;
68 PMA_DBI_free_result($db_info_result);
70 if (isset($sot_cache)) {
71 $db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . $tbl_group_sql . ';', null, PMA_DBI_QUERY_STORE);
72 if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
73 while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
74 if (!isset($sot_cache[$tmp[0]])) {
75 $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
76 $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
77 PMA_DBI_free_result($sts_result);
78 unset($sts_result);
80 if (!isset($sts_tmp['Type']) && isset($sts_tmp['Engine'])) {
81 $sts_tmp['Type'] =& $sts_tmp['Engine'];
84 if (!empty($tbl_group) && $cfg['ShowTooltipAliasTB'] && !preg_match('@' . preg_quote($tbl_group, '@') . '@i', $sts_tmp['Comment'])) {
85 continue;
88 if ($cfg['ShowTooltip']) {
89 fillTooltip($tooltip_truename, $tooltip_aliasname, $sts_tmp);
92 $tables[$sts_tmp['Name']] = $sts_tmp;
93 } else { // table in use
94 $tables[$tmp[0]] = array('Name' => $tmp[0]);
97 PMA_DBI_free_result($db_info_result);
99 if ( $GLOBALS['cfg']['NaturalOrder'] ) {
100 uksort( $tables, 'strnatcasecmp' );
103 $sot_ready = TRUE;
106 } else {
107 PMA_DBI_free_result($db_info_result);
108 unset($db_info_result);
112 if ( ! isset( $sot_ready ) ) {
113 if ( ! empty( $tbl_group ) && ! $cfg['ShowTooltipAliasTB'] ) {
114 // only tables for selected group
115 $tables = PMA_DBI_get_tables_full( $db, $tbl_group, true );
116 } elseif ( ! empty( $tbl_group ) && $cfg['ShowTooltipAliasTB'] ) {
117 // only tables for selected group,
118 // but grouping is done on comment ...
119 $tables = PMA_DBI_get_tables_full( $db, $tbl_group, 'comment' );
120 } else {
121 // all tables in db
122 $tables = PMA_DBI_get_tables_full( $db );
125 if ( $cfg['ShowTooltip'] ) {
126 foreach ( $tables as $each_table ) {
127 fillTooltip( $tooltip_truename, $tooltip_aliasname, $each_table );
132 $num_tables = count( $tables );
135 * Displays top menu links
137 require('./libraries/db_details_links.inc.php');