Translated using Weblate (Traditional Chinese)
[phpmyadmin.git] / db_printview.php
blobe0c2f14234b4d9857ba6226950ffca8077a05831
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package PhpMyAdmin
6 */
8 /**
11 require_once 'libraries/common.inc.php';
13 $response = PMA_Response::getInstance();
14 $header = $response->getHeader();
15 $header->enablePrintView();
17 PMA_Util::checkParameters(array('db'));
19 /**
20 * Defines the url to return to in case of error in a sql statement
22 $err_url = 'db_sql.php?' . PMA_generate_common_url($db);
24 /**
25 * Settings for relations stuff
27 $cfgRelation = PMA_getRelationsParam();
29 /**
30 * Gets the list of the table in the current db and informations about these
31 * tables if possible
33 * @todo merge this speedup _optionaly_ into PMA_DBI_get_tables_full()
35 // speedup view on locked tables
36 // Special speedup for newer MySQL Versions (in 4.0 format changed)
37 if ($cfg['SkipLockedTables'] == true) {
38 $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_Util::backquote($db) . ';');
39 // Blending out tables in use
40 if ($result != false && PMA_DBI_num_rows($result) > 0) {
41 while ($tmp = PMA_DBI_fetch_row($result)) {
42 // if in use memorize tablename
43 if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
44 $sot_cache[$tmp[0]] = true;
47 PMA_DBI_free_result($result);
49 if (isset($sot_cache)) {
50 $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_Util::backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
51 if ($result != false && PMA_DBI_num_rows($result) > 0) {
52 while ($tmp = PMA_DBI_fetch_row($result)) {
53 if (! isset($sot_cache[$tmp[0]])) {
54 $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_Util::backquote($db) . ' LIKE \'' . sqlAddSlashes($tmp[0], true) . '\';');
55 $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
56 $tables[] = $sts_tmp;
57 } else { // table in use
58 $tables[] = array('Name' => $tmp[0]);
61 PMA_DBI_free_result($result);
62 $sot_ready = true;
65 unset($tmp, $result);
69 if (! isset($sot_ready)) {
70 $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_Util::backquote($db) . ';');
71 if (PMA_DBI_num_rows($result) > 0) {
72 while ($sts_tmp = PMA_DBI_fetch_assoc($result)) {
73 $tables[] = $sts_tmp;
75 PMA_DBI_free_result($result);
76 unset($res);
81 /**
82 * If there is at least one table, displays the printer friendly view, else
83 * an error message
85 $tables = PMA_DBI_get_tables_full($db);
86 $num_tables = count($tables);
88 echo '<br />';
90 // 1. No table
91 if ($num_tables == 0) {
92 echo __('No tables found in database.');
93 } else {
94 // 2. Shows table information
96 <table>
97 <thead>
98 <tr>
99 <th><?php echo __('Table'); ?></th>
100 <th><?php echo __('Rows'); ?></th>
101 <th><?php echo __('Type'); ?></th>
102 <?php
103 if ($cfg['ShowStats']) {
104 echo '<th>' . __('Size') . '</th>';
107 <th><?php echo __('Comments'); ?></th>
108 </tr>
109 </thead>
110 <tbody>
111 <?php
112 $sum_entries = $sum_size = 0;
113 $odd_row = true;
114 foreach ($tables as $sts_data) {
115 if (PMA_Table::isMerge($db, $sts_data['TABLE_NAME'])
116 || strtoupper($sts_data['ENGINE']) == 'FEDERATED'
118 $merged_size = true;
119 } else {
120 $merged_size = false;
122 $sum_entries += $sts_data['TABLE_ROWS'];
124 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
125 <th>
126 <?php echo htmlspecialchars($sts_data['TABLE_NAME']); ?>
127 </th>
128 <?php
130 if (isset($sts_data['TABLE_ROWS'])) {
132 <td class="right">
133 <?php
134 if ($merged_size) {
135 echo '<i>' . PMA_Util::formatNumber($sts_data['TABLE_ROWS'], 0) . '</i>' . "\n";
136 } else {
137 echo PMA_Util::formatNumber($sts_data['TABLE_ROWS'], 0) . "\n";
140 </td>
141 <td class="nowrap">
142 <?php echo $sts_data['ENGINE']; ?>
143 </td>
144 <?php
145 if ($cfg['ShowStats']) {
146 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
147 $sum_size += $tblsize;
148 list($formated_size, $unit)
149 = PMA_Util::formatByteDown($tblsize, 3, 1);
151 <td class="right nowrap">
152 <?php echo $formated_size . ' ' . $unit; ?>
153 </td>
154 <?php
155 } // end if
156 } else {
158 <td colspan="3" class="center">
159 <?php echo __('in use'); ?>
160 </td>
161 <?php
164 <td>
165 <?php
166 if (! empty($sts_data['Comment'])) {
167 echo htmlspecialchars($sts_data['Comment']);
168 $needs_break = '<br />';
169 } else {
170 $needs_break = '';
173 if (! empty($sts_data['Create_time'])
174 || ! empty($sts_data['Update_time'])
175 || ! empty($sts_data['Check_time'])
177 echo $needs_break;
179 <table width="100%">
180 <?php
182 if (! empty($sts_data['Create_time'])) {
184 <tr>
185 <td class="right"><?php echo __('Creation') . ': '; ?></td>
186 <td class="right"><?php echo PMA_Util::localisedDate(strtotime($sts_data['Create_time'])); ?></td>
187 </tr>
188 <?php
191 if (! empty($sts_data['Update_time'])) {
193 <tr>
194 <td class="right"><?php echo __('Last update') . ': '; ?></td>
195 <td class="right"><?php echo PMA_Util::localisedDate(strtotime($sts_data['Update_time'])); ?></td>
196 </tr>
197 <?php
200 if (! empty($sts_data['Check_time'])) {
202 <tr>
203 <td class="right"><?php echo __('Last check') . ': '; ?></td>
204 <td class="right"><?php echo PMA_Util::localisedDate(strtotime($sts_data['Check_time'])); ?></td>
205 </tr>
206 <?php
209 </table>
210 <?php
213 </td>
214 </tr>
215 <?php
218 <tr>
219 <th class="center">
220 <?php echo sprintf(_ngettext('%s table', '%s tables', $num_tables), PMA_Util::formatNumber($num_tables, 0)); ?>
221 </th>
222 <th class="right nowrap">
223 <?php echo PMA_Util::formatNumber($sum_entries, 0); ?>
224 </th>
225 <th class="center">
227 </th>
228 <?php
229 if ($cfg['ShowStats']) {
230 list($sum_formated, $unit)
231 = PMA_Util::formatByteDown($sum_size, 3, 1);
233 <th class="right nowrap">
234 <?php echo $sum_formated . ' ' . $unit; ?>
235 </th>
236 <?php
239 <th></th>
240 </tr>
241 </tbody>
242 </table>
243 <?php
247 * Displays the footer
249 echo PMA_Util::getButton();
251 echo "<div id='PMA_disable_floating_menubar'></div>\n";