Rev Author Line No. Line
250 kaklik 1 <?php
2 /* $Id: db_details_db_info.inc.php,v 1.2 2006/01/17 17:02:30 cybot_tm Exp $ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4  
5  
6 // Check parameters
7  
8 require_once('./libraries/common.lib.php');
9  
10 PMA_checkParameters(array('db'));
11  
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;
17 }
18  
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']));
24 }
25  
26 if (isset($tmp['Update_time']) && !empty($tmp['Update_time'])) {
27 $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Update_time']));
28 }
29  
30 if (isset($tmp['Check_time']) && !empty($tmp['Check_time'])) {
31 $tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Check_time']));
32 }
33  
34 return true;
35 }
36  
37 /**
38 * Gets the list of the table in the current db and informations about these
39 * tables if possible
40 */
41 // staybyte: speedup view on locked tables - 11 June 2001
42 $tables = array();
43  
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 = '';
49 }
50  
51 if ( $cfg['ShowTooltip'] ) {
52 $tooltip_truename = array();
53 $tooltip_aliasname = array();
54 }
55  
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) . ';');
59  
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;
66 }
67 }
68 PMA_DBI_free_result($db_info_result);
69  
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);
79  
80 if (!isset($sts_tmp['Type']) && isset($sts_tmp['Engine'])) {
81 $sts_tmp['Type'] =& $sts_tmp['Engine'];
82 }
83  
84 if (!empty($tbl_group) && $cfg['ShowTooltipAliasTB'] && !preg_match('@' . preg_quote($tbl_group, '@') . '@i', $sts_tmp['Comment'])) {
85 continue;
86 }
87  
88 if ($cfg['ShowTooltip']) {
89 fillTooltip($tooltip_truename, $tooltip_aliasname, $sts_tmp);
90 }
91  
92 $tables[$sts_tmp['Name']] = $sts_tmp;
93 } else { // table in use
94 $tables[$tmp[0]] = array('Name' => $tmp[0]);
95 }
96 }
97 PMA_DBI_free_result($db_info_result);
98  
99 if ( $GLOBALS['cfg']['NaturalOrder'] ) {
100 uksort( $tables, 'strnatcasecmp' );
101 }
102  
103 $sot_ready = TRUE;
104 }
105 }
106 } else {
107 PMA_DBI_free_result($db_info_result);
108 unset($db_info_result);
109 }
110 }
111  
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 );
123 }
124  
125 if ( $cfg['ShowTooltip'] ) {
126 foreach ( $tables as $each_table ) {
127 fillTooltip( $tooltip_truename, $tooltip_aliasname, $each_table );
128 }
129 }
130 }
131  
132 $num_tables = count( $tables );
133  
134 /**
135 * Displays top menu links
136 */
137 require('./libraries/db_details_links.inc.php');
138 ?>