fixed bug 'no tables found', refactored

This commit is contained in:
Sebastian Mendel
2006-04-27 09:42:22 +00:00
parent 7d156b3f62
commit 57e522d2c8
2 changed files with 81 additions and 118 deletions

View File

@@ -5,6 +5,9 @@ phpMyAdmin - ChangeLog
$Id$ $Id$
$Source$ $Source$
2006-04-27 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* db_printview.php: fixed bug 'no tables found', refactored
2006-04-27 Michal Čihař <michal@cihar.com> 2006-04-27 Michal Čihař <michal@cihar.com>
* Documentation.html, libraries/config.default.php, * Documentation.html, libraries/config.default.php,
libraries/auth/cookie.auth.lib.php: Logout from all servers by default libraries/auth/cookie.auth.lib.php: Logout from all servers by default

View File

@@ -10,7 +10,6 @@ require_once './libraries/common.lib.php';
$print_view = true; $print_view = true;
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';
PMA_checkParameters(array('db')); PMA_checkParameters(array('db'));
/** /**
@@ -27,7 +26,9 @@ $cfgRelation = PMA_getRelationsParam();
/** /**
* Gets the list of the table in the current db and informations about these * Gets the list of the table in the current db and informations about these
* tables if possible * tables if possible
*/ *
* @todo merge this speedup _optionaly_ into PMA_DBI_get_tables_full()
*
// staybyte: speedup view on locked tables - 11 June 2001 // staybyte: speedup view on locked tables - 11 June 2001
// Special speedup for newer MySQL Versions (in 4.0 format changed) // Special speedup for newer MySQL Versions (in 4.0 format changed)
if ($cfg['SkipLockedTables'] == true) { if ($cfg['SkipLockedTables'] == true) {
@@ -41,7 +42,6 @@ if ($cfg['SkipLockedTables'] == true) {
} }
} }
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
unset($result);
if (isset($sot_cache)) { if (isset($sot_cache)) {
$result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE); $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
@@ -56,14 +56,14 @@ if ($cfg['SkipLockedTables'] == true) {
} }
} }
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
unset($result);
$sot_ready = true; $sot_ready = true;
} }
} }
unset($tmp, $result);
} }
} }
if (!isset($sot_ready)) { if (! isset($sot_ready)) {
$result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';'); $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
if (PMA_DBI_num_rows($result) > 0) { if (PMA_DBI_num_rows($result) > 0) {
while ($sts_tmp = PMA_DBI_fetch_assoc($result)) { while ($sts_tmp = PMA_DBI_fetch_assoc($result)) {
@@ -73,28 +73,17 @@ if (!isset($sot_ready)) {
unset($res); unset($res);
} }
} }
$num_tables = isset($tables) ? count($tables) : 0; */
if ($cfgRelation['commwork']) {
$comment = PMA_getComments($db);
/**
* Displays DB comment
*/
if (is_array($comment)) {
?>
<!-- DB comment -->
<p><i>
<?php echo htmlspecialchars(implode(' ', $comment)); ?>
</i></p>
<?php
} // end if
}
/** /**
* If there is at least one table, displays the printer friendly view, else * If there is at least one table, displays the printer friendly view, else
* an error message * an error message
*/ */
$tables = PMA_DBI_get_tables_full($db);
$num_tables = count($tables);
echo '<br />';
// 1. No table // 1. No table
if ($num_tables == 0) { if ($num_tables == 0) {
echo $strNoTablesFound; echo $strNoTablesFound;
@@ -102,12 +91,10 @@ if ($num_tables == 0) {
// 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
else { else {
?> ?>
<table>
<!-- The tables list -->
<table border="<?php echo $cfg['Border']; ?>">
<thead> <thead>
<tr> <tr>
<th>&nbsp;<?php echo $strTable; ?>&nbsp;</th> <th><?php echo $strTable; ?></th>
<th><?php echo $strRecords; ?></th> <th><?php echo $strRecords; ?></th>
<th><?php echo $strType; ?></th> <th><?php echo $strType; ?></th>
<?php <?php
@@ -119,70 +106,46 @@ else {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
$i = $sum_entries = $sum_size = 0; $sum_entries = $sum_size = 0;
$odd_row = true; $odd_row = true;
foreach ($tables as $keyname => $sts_data) { foreach ($tables as $sts_data) {
$table = $sts_data['Name']; if (strtoupper($sts_data['ENGINE']) == 'MRG_MYISAM'
|| strtoupper($sts_data['ENGINE']) == 'FEDERATED') {
$merged_size = true;
} else {
$merged_size = false;
}
$sum_entries += $sts_data['TABLE_ROWS'];
?> ?>
<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>"> <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
<td nowrap="nowrap"> <th>
&nbsp;<b><?php echo htmlspecialchars($table); ?>&nbsp;</b>&nbsp; <?php echo htmlspecialchars($sts_data['TABLE_NAME']); ?>
</td> </th>
<?php <?php
$mergetable = false;
$nonisam = false;
if (isset($sts_data['Type'])) {
if ($sts_data['Type'] == 'MRG_MyISAM') {
$mergetable = true;
} elseif (!preg_match('@ISAM|HEAP@i', $sts_data['Type'])) {
$nonisam = true;
}
}
if (isset($sts_data['Rows'])) { if (isset($sts_data['TABLE_ROWS'])) {
if ($mergetable == false) {
if ($cfg['ShowStats'] && $nonisam == false) {
$tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
$sum_size += $tblsize;
if ($tblsize > 0) {
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
} else {
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
}
} elseif ($cfg['ShowStats']) {
$formated_size = '&nbsp;-&nbsp;';
$unit = '';
}
$sum_entries += $sts_data['Rows'];
}
// MyISAM MERGE Table
elseif ($cfg['ShowStats'] && $mergetable == true) {
$formated_size = '&nbsp;-&nbsp;';
$unit = '';
} elseif ($cfg['ShowStats']) {
$formated_size = 'unknown';
$unit = '';
}
?> ?>
<td align="right"> <td align="right">
<?php <?php
if ($mergetable == true) { if ($merged_size) {
echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n"; echo '<i>' . number_format($sts_data['TABLE_ROWS'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
} else { } else {
echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; echo number_format($sts_data['TABLE_ROWS'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
} }
?> ?>
</td> </td>
<td nowrap="nowrap"> <td nowrap="nowrap">
&nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp; <?php echo $sts_data['ENGINE']; ?>
</td> </td>
<?php <?php
if ($cfg['ShowStats']) { if ($cfg['ShowStats']) {
$tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
$sum_size += $tblsize;
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
?> ?>
<td align="right" nowrap="nowrap"> <td align="right" nowrap="nowrap">
&nbsp;<?php echo $formated_size . ' ' . $unit . "\n"; ?> <?php echo $formated_size . ' ' . $unit; ?>
</td> </td>
<?php <?php
} // end if } // end if
@@ -195,65 +158,61 @@ else {
} }
?> ?>
<td> <td>
<?php echo $sts_data['Comment']; ?>
<?php <?php
if (!empty($sts_data['Comment'])) { if (! empty($sts_data['Comment'])) {
$needs_break = '<br />'; echo $sts_data['Comment'];
} else { $needs_break = '<br />';
$needs_break = ''; } else {
} $needs_break = '';
}
if ((isset($sts_data['Create_time']) && !empty($sts_data['Create_time'])) if (! empty($sts_data['Create_time'])
|| (isset($sts_data['Update_time']) && !empty($sts_data['Update_time'])) || ! empty($sts_data['Update_time'])
|| (isset($sts_data['Check_time']) && !empty($sts_data['Check_time']))) { || ! empty($sts_data['Check_time'])) {
echo $needs_break; echo $needs_break;
?>
<table width="100%">
<?php
if (! empty($sts_data['Create_time'])) {
?> ?>
<table border="0" cellpadding="1" cellspacing="1" width="100%" class="noborder"> <tr>
<?php <td align="right"><?php echo $strStatCreateTime . ': '; ?></td>
<td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
if (isset($sts_data['Create_time']) && !empty($sts_data['Create_time'])) { </tr>
?>
<tr>
<td style="font-size: 80%" align="right"><?php echo $strStatCreateTime . ': '; ?></td>
<td style="font-size: 80%" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
</tr>
<?php
}
if (isset($sts_data['Update_time']) && !empty($sts_data['Update_time'])) {
?>
<tr>
<td style="font-size: 80%" align="right"><?php echo $strStatUpdateTime . ': '; ?></td>
<td style="font-size: 80%" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
</tr>
<?php
}
if (isset($sts_data['Check_time']) && !empty($sts_data['Check_time'])) {
?>
<tr>
<td style="font-size: 80%" align="right"><?php echo $strStatCheckTime . ': '; ?></td>
<td style="font-size: 80%" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
</tr>
<?php
}
?>
</table>
<?php <?php
} }
if (! empty($sts_data['Update_time'])) {
?>
<tr>
<td align="right"><?php echo $strStatUpdateTime . ': '; ?></td>
<td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
</tr>
<?php
}
if (! empty($sts_data['Check_time'])) {
?>
<tr>
<td align="right"><?php echo $strStatCheckTime . ': '; ?></td>
<td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?> ?>
</td> </td>
</tr> </tr>
<?php <?php
} }
// Show Summary
if ($cfg['ShowStats']) {
list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
}
?> ?>
<tr> <tr>
<th align="center"> <th align="center">
&nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp; <?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?>
</th> </th>
<th align="right" nowrap="nowrap"> <th align="right" nowrap="nowrap">
<?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?> <?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?>
@@ -263,6 +222,7 @@ else {
</th> </th>
<?php <?php
if ($cfg['ShowStats']) { if ($cfg['ShowStats']) {
list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
?> ?>
<th align="right" nowrap="nowrap"> <th align="right" nowrap="nowrap">
<?php echo $sum_formated . ' ' . $unit; ?> <?php echo $sum_formated . ' ' . $unit; ?>
@@ -295,7 +255,7 @@ function printPage()
</script> </script>
<br /><br /> <br /><br />
<input type="button" class="print_ignore" style="width: 100px; height: 25px" <input type="button" class="print_ignore"
id="print" value="<?php echo $strPrint; ?>" onclick="printPage()" /> id="print" value="<?php echo $strPrint; ?>" onclick="printPage()" />
<?php <?php