source: www/mysql/db_printview.php@ 1

Last change on this file since 1 was 1, checked in by george, 17 years ago

Prvotní import všeho

File size: 7.4 KB
Line 
1<?php
2/* $Id: db_printview.php 9602 2006-10-25 12:25:01Z nijel $ */
3// vim: expandtab sw=4 ts=4 sts=4:
4
5require_once './libraries/common.lib.php';
6
7/**
8 * Gets the variables sent or posted to this script, then displays headers
9 */
10$print_view = true;
11require_once './libraries/header.inc.php';
12
13PMA_checkParameters(array('db'));
14
15/**
16 * Defines the url to return to in case of error in a sql statement
17 */
18$err_url = 'db_sql.php?' . PMA_generate_common_url($db);
19
20/**
21 * Settings for relations stuff
22 */
23require_once './libraries/relation.lib.php';
24$cfgRelation = PMA_getRelationsParam();
25
26/**
27 * Gets the list of the table in the current db and informations about these
28 * tables if possible
29 *
30 * @todo merge this speedup _optionaly_ into PMA_DBI_get_tables_full()
31 *
32// staybyte: speedup view on locked tables - 11 June 2001
33// Special speedup for newer MySQL Versions (in 4.0 format changed)
34if ($cfg['SkipLockedTables'] == true) {
35 $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
36 // Blending out tables in use
37 if ($result != false && PMA_DBI_num_rows($result) > 0) {
38 while ($tmp = PMA_DBI_fetch_row($result)) {
39 // if in use memorize tablename
40 if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
41 $sot_cache[$tmp[0]] = true;
42 }
43 }
44 PMA_DBI_free_result($result);
45
46 if (isset($sot_cache)) {
47 $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
48 if ($result != false && PMA_DBI_num_rows($result) > 0) {
49 while ($tmp = PMA_DBI_fetch_row($result)) {
50 if (!isset($sot_cache[$tmp[0]])) {
51 $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
52 $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
53 $tables[] = $sts_tmp;
54 } else { // table in use
55 $tables[] = array('Name' => $tmp[0]);
56 }
57 }
58 PMA_DBI_free_result($result);
59 $sot_ready = true;
60 }
61 }
62 unset($tmp, $result);
63 }
64}
65
66if (! isset($sot_ready)) {
67 $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
68 if (PMA_DBI_num_rows($result) > 0) {
69 while ($sts_tmp = PMA_DBI_fetch_assoc($result)) {
70 $tables[] = $sts_tmp;
71 }
72 PMA_DBI_free_result($result);
73 unset($res);
74 }
75}
76 */
77
78/**
79 * If there is at least one table, displays the printer friendly view, else
80 * an error message
81 */
82$tables = PMA_DBI_get_tables_full($db);
83$num_tables = count($tables);
84
85echo '<br />';
86
87// 1. No table
88if ($num_tables == 0) {
89 echo $strNoTablesFound;
90}
91// 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
92else {
93 ?>
94<table>
95<thead>
96<tr>
97 <th><?php echo $strTable; ?></th>
98 <th><?php echo $strRecords; ?></th>
99 <th><?php echo $strType; ?></th>
100 <?php
101 if ($cfg['ShowStats']) {
102 echo '<th>' . $strSize . '</th>';
103 }
104 ?>
105 <th><?php echo $strComments; ?></th>
106</tr>
107</thead>
108<tbody>
109 <?php
110 $sum_entries = $sum_size = 0;
111 $odd_row = true;
112 foreach ($tables as $sts_data) {
113 if (strtoupper($sts_data['ENGINE']) == 'MRG_MYISAM'
114 || strtoupper($sts_data['ENGINE']) == 'FEDERATED') {
115 $merged_size = true;
116 } else {
117 $merged_size = false;
118 }
119 $sum_entries += $sts_data['TABLE_ROWS'];
120 ?>
121<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
122 <th>
123 <?php echo htmlspecialchars($sts_data['TABLE_NAME']); ?>
124 </th>
125 <?php
126
127 if (isset($sts_data['TABLE_ROWS'])) {
128 ?>
129 <td align="right">
130 <?php
131 if ($merged_size) {
132 echo '<i>' . number_format($sts_data['TABLE_ROWS'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
133 } else {
134 echo number_format($sts_data['TABLE_ROWS'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
135 }
136 ?>
137 </td>
138 <td nowrap="nowrap">
139 <?php echo $sts_data['ENGINE']; ?>
140 </td>
141 <?php
142 if ($cfg['ShowStats']) {
143 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
144 $sum_size += $tblsize;
145 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
146 ?>
147 <td align="right" nowrap="nowrap">
148 <?php echo $formated_size . ' ' . $unit; ?>
149 </td>
150 <?php
151 } // end if
152 } else {
153 ?>
154 <td colspan="3" align="center">
155 <?php echo $strInUse; ?>
156 </td>
157 <?php
158 }
159 ?>
160 <td>
161 <?php
162 if (! empty($sts_data['Comment'])) {
163 echo $sts_data['Comment'];
164 $needs_break = '<br />';
165 } else {
166 $needs_break = '';
167 }
168
169 if (! empty($sts_data['Create_time'])
170 || ! empty($sts_data['Update_time'])
171 || ! empty($sts_data['Check_time'])) {
172 echo $needs_break;
173 ?>
174 <table width="100%">
175 <?php
176
177 if (! empty($sts_data['Create_time'])) {
178 ?>
179 <tr>
180 <td align="right"><?php echo $strStatCreateTime . ': '; ?></td>
181 <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
182 </tr>
183 <?php
184 }
185
186 if (! empty($sts_data['Update_time'])) {
187 ?>
188 <tr>
189 <td align="right"><?php echo $strStatUpdateTime . ': '; ?></td>
190 <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
191 </tr>
192 <?php
193 }
194
195 if (! empty($sts_data['Check_time'])) {
196 ?>
197 <tr>
198 <td align="right"><?php echo $strStatCheckTime . ': '; ?></td>
199 <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
200 </tr>
201 <?php
202 }
203 ?>
204 </table>
205 <?php
206 }
207 ?>
208 </td>
209</tr>
210 <?php
211 }
212 ?>
213<tr>
214 <th align="center">
215 <?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?>
216 </th>
217 <th align="right" nowrap="nowrap">
218 <?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?>
219 </th>
220 <th align="center">
221 --
222 </th>
223 <?php
224 if ($cfg['ShowStats']) {
225 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
226 ?>
227 <th align="right" nowrap="nowrap">
228 <?php echo $sum_formated . ' ' . $unit; ?>
229 </th>
230 <?php
231 }
232 ?>
233 <th>&nbsp;</th>
234</tr>
235</tbody>
236</table>
237 <?php
238}
239
240/**
241 * Displays the footer
242 */
243?>
244
245<script type="text/javascript" language="javascript">
246//<![CDATA[
247function printPage()
248{
249 // Do print the page
250 if (typeof(window.print) != 'undefined') {
251 window.print();
252 }
253}
254//]]>
255</script>
256<br /><br />
257
258<input type="button" class="print_ignore"
259 id="print" value="<?php echo $strPrint; ?>" onclick="printPage()" />
260
261<?php
262require_once './libraries/footer.inc.php';
263?>
Note: See TracBrowser for help on using the repository browser.