2 /* vim: set expandtab sw=4 ts=4 sts=4: */
11 require_once 'libraries/common.inc.php';
14 * Gets the variables sent or posted to this script, then displays headers
17 require_once 'libraries/header.inc.php';
19 PMA_checkParameters(array('db'));
22 * Defines the url to return to in case of error in a sql statement
24 $err_url = 'db_sql.php?' . PMA_generate_common_url($db);
27 * Settings for relations stuff
29 $cfgRelation = PMA_getRelationsParam();
32 * Gets the list of the table in the current db and informations about these
35 * @todo merge this speedup _optionaly_ into PMA_DBI_get_tables_full()
37 // speedup view on locked tables
38 // Special speedup for newer MySQL Versions (in 4.0 format changed)
39 if ($cfg['SkipLockedTables'] == true) {
40 $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
41 // Blending out tables in use
42 if ($result != false && PMA_DBI_num_rows($result) > 0) {
43 while ($tmp = PMA_DBI_fetch_row($result)) {
44 // if in use memorize tablename
45 if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
46 $sot_cache[$tmp[0]] = true;
49 PMA_DBI_free_result($result);
51 if (isset($sot_cache)) {
52 $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
53 if ($result != false && PMA_DBI_num_rows($result) > 0) {
54 while ($tmp = PMA_DBI_fetch_row($result)) {
55 if (! isset($sot_cache[$tmp[0]])) {
56 $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddSlashes($tmp[0], true) . '\';');
57 $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
59 } else { // table in use
60 $tables[] = array('Name' => $tmp[0]);
63 PMA_DBI_free_result($result);
71 if (! isset($sot_ready)) {
72 $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
73 if (PMA_DBI_num_rows($result) > 0) {
74 while ($sts_tmp = PMA_DBI_fetch_assoc($result)) {
77 PMA_DBI_free_result($result);
84 * If there is at least one table, displays the printer friendly view, else
87 $tables = PMA_DBI_get_tables_full($db);
88 $num_tables = count($tables);
93 if ($num_tables == 0) {
94 echo __('No tables found in database.');
96 // 2. Shows table information
101 <th
><?php
echo __('Table'); ?
></th
>
102 <th
><?php
echo __('Rows'); ?
></th
>
103 <th
><?php
echo __('Type'); ?
></th
>
105 if ($cfg['ShowStats']) {
106 echo '<th>' . __('Size') . '</th>';
109 <th
><?php
echo __('Comments'); ?
></th
>
114 $sum_entries = $sum_size = 0;
116 foreach ($tables as $sts_data) {
117 if (PMA_Table
::isMerge($db, $sts_data['TABLE_NAME'])
118 ||
strtoupper($sts_data['ENGINE']) == 'FEDERATED'
122 $merged_size = false;
124 $sum_entries +
= $sts_data['TABLE_ROWS'];
126 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
128 <?php
echo htmlspecialchars($sts_data['TABLE_NAME']); ?
>
132 if (isset($sts_data['TABLE_ROWS'])) {
137 echo '<i>' . PMA_formatNumber($sts_data['TABLE_ROWS'], 0) . '</i>' . "\n";
139 echo PMA_formatNumber($sts_data['TABLE_ROWS'], 0) . "\n";
144 <?php
echo $sts_data['ENGINE']; ?
>
147 if ($cfg['ShowStats']) {
148 $tblsize = $sts_data['Data_length'] +
$sts_data['Index_length'];
149 $sum_size +
= $tblsize;
150 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
152 <td
class="right nowrap">
153 <?php
echo $formated_size . ' ' . $unit; ?
>
159 <td colspan
="3" class="center">
160 <?php
echo __('in use'); ?
>
167 if (! empty($sts_data['Comment'])) {
168 echo htmlspecialchars($sts_data['Comment']);
169 $needs_break = '<br />';
174 if (! empty($sts_data['Create_time'])
175 ||
! empty($sts_data['Update_time'])
176 ||
! empty($sts_data['Check_time'])
183 if (! empty($sts_data['Create_time'])) {
186 <td
class="right"><?php
echo __('Creation') . ': '; ?
></td
>
187 <td
class="right"><?php
echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?
></td
>
192 if (! empty($sts_data['Update_time'])) {
195 <td
class="right"><?php
echo __('Last update') . ': '; ?
></td
>
196 <td
class="right"><?php
echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?
></td
>
201 if (! empty($sts_data['Check_time'])) {
204 <td
class="right"><?php
echo __('Last check') . ': '; ?
></td
>
205 <td
class="right"><?php
echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?
></td
>
221 <?php
echo sprintf(_ngettext('%s table', '%s tables', $num_tables), PMA_formatNumber($num_tables, 0)); ?
>
223 <th
class="right nowrap">
224 <?php
echo PMA_formatNumber($sum_entries, 0); ?
>
230 if ($cfg['ShowStats']) {
231 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
233 <th
class="right nowrap">
234 <?php
echo $sum_formated . ' ' . $unit; ?
>
247 * Displays the footer
251 echo "<div id='PMA_disable_floating_menubar'></div>\n";
253 require 'libraries/footer.inc.php';