2 /* vim: set expandtab sw=4 ts=4 sts=4: */
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'));
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);
25 * Settings for relations stuff
27 $cfgRelation = PMA_getRelationsParam();
30 * Gets the list of the table in the current db and informations about these
33 * @todo merge this speedup _optionaly_ into PMA_DBI_getTablesFull()
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_numRows($result) > 0) {
41 while ($tmp = PMA_DBI_fetchRow($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_freeResult($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_numRows($result) > 0) {
52 while ($tmp = PMA_DBI_fetchRow($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_fetchAssoc($sts_result);
57 } else { // table in use
58 $tables[] = array('Name' => $tmp[0]);
61 PMA_DBI_freeResult($result);
69 if (! isset($sot_ready)) {
70 $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_Util::backquote($db) . ';');
71 if (PMA_DBI_numRows($result) > 0) {
72 while ($sts_tmp = PMA_DBI_fetchAssoc($result)) {
75 PMA_DBI_freeResult($result);
82 * If there is at least one table, displays the printer friendly view, else
85 $tables = PMA_DBI_getTablesFull($db);
86 $num_tables = count($tables);
91 if ($num_tables == 0) {
92 echo __('No tables found in database.');
94 // 2. Shows table information
99 <th
><?php
echo __('Table'); ?
></th
>
100 <th
><?php
echo __('Rows'); ?
></th
>
101 <th
><?php
echo __('Type'); ?
></th
>
103 if ($cfg['ShowStats']) {
104 echo '<th>' . __('Size') . '</th>';
107 <th
><?php
echo __('Comments'); ?
></th
>
112 $sum_entries = $sum_size = 0;
114 foreach ($tables as $sts_data) {
115 if (PMA_Table
::isMerge($db, $sts_data['TABLE_NAME'])
116 ||
strtoupper($sts_data['ENGINE']) == 'FEDERATED'
120 $merged_size = false;
122 $sum_entries +
= $sts_data['TABLE_ROWS'];
124 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
126 <?php
echo htmlspecialchars($sts_data['TABLE_NAME']); ?
>
130 if (isset($sts_data['TABLE_ROWS'])) {
135 echo '<i>' . PMA_Util
::formatNumber($sts_data['TABLE_ROWS'], 0) . '</i>' . "\n";
137 echo PMA_Util
::formatNumber($sts_data['TABLE_ROWS'], 0) . "\n";
142 <?php
echo $sts_data['ENGINE']; ?
>
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; ?
>
158 <td colspan
="3" class="center">
159 <?php
echo __('in use'); ?
>
166 if (! empty($sts_data['Comment'])) {
167 echo htmlspecialchars($sts_data['Comment']);
168 $needs_break = '<br />';
173 if (! empty($sts_data['Create_time'])
174 ||
! empty($sts_data['Update_time'])
175 ||
! empty($sts_data['Check_time'])
182 if (! empty($sts_data['Create_time'])) {
185 <td
class="right"><?php
echo __('Creation:'); ?
></td
>
186 <td
class="right"><?php
echo PMA_Util
::localisedDate(strtotime($sts_data['Create_time'])); ?
></td
>
191 if (! empty($sts_data['Update_time'])) {
194 <td
class="right"><?php
echo __('Last update:'); ?
></td
>
195 <td
class="right"><?php
echo PMA_Util
::localisedDate(strtotime($sts_data['Update_time'])); ?
></td
>
200 if (! empty($sts_data['Check_time'])) {
203 <td
class="right"><?php
echo __('Last check:'); ?
></td
>
204 <td
class="right"><?php
echo PMA_Util
::localisedDate(strtotime($sts_data['Check_time'])); ?
></td
>
220 <?php
echo sprintf(_ngettext('%s table', '%s tables', $num_tables), PMA_Util
::formatNumber($num_tables, 0)); ?
>
222 <th
class="right nowrap">
223 <?php
echo PMA_Util
::formatNumber($sum_entries, 0); ?
>
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; ?
>
247 * Displays the footer
249 echo PMA_Util
::getButton();
251 echo "<div id='PMA_disable_floating_menubar'></div>\n";