2.2.4
[phpmyadmin/arisferyanto.git] / db_printview.php3
blobee8928f7eb8585c12fb9019643b9175fb9f30e5c
1 <?php
2 /* $Id$ */
5 /**
6 * Gets the variables sent or posted to this script, then displays headers
7 */
8 require('./libraries/grab_globals.lib.php3');
9 require('./header.inc.php3');
12 /**
13 * Defines the url to return to in case of error in a sql statement
15 $err_url = 'db_details.php3'
16 . '?lang=' . $lang
17 . '&amp;server=' . $server
18 . '&amp;db=' . urlencode($db);
21 /**
22 * Gets the list of the table in the current db and informations about these
23 * tables if possible
25 // staybyte: speedup view on locked tables - 11 June 2001
26 if (PMA_MYSQL_INT_VERSION >= 32303) {
27 // Special speedup for newer MySQL Versions (in 4.0 format changed)
28 if ($cfgSkipLockedTables == TRUE && PMA_MYSQL_INT_VERSION >= 32330) {
29 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
30 $result = mysql_query($query) or PMA_mysqlDie('', $local_query, '', $err_url);
31 // Blending out tables in use
32 if ($result != FALSE && mysql_num_rows($result) > 0) {
33 while ($tmp = mysql_fetch_array($result)) {
34 // if in use memorize tablename
35 if (eregi('in_use=[1-9]+', $tmp)) {
36 $sot_cache[$tmp[0]] = TRUE;
39 mysql_free_result($result);
41 if (isset($sot_cache)) {
42 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
43 $result = mysql_query($query) or PMA_mysqlDie('', $local_query, '', $err_url);
44 if ($result != FALSE && mysql_num_rows($result) > 0) {
45 while ($tmp = mysql_fetch_array($result)) {
46 if (!isset($sot_cache[$tmp[0]])) {
47 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
48 $sts_result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
49 $sts_tmp = mysql_fetch_array($sts_result);
50 $tables[] = $sts_tmp;
51 } else { // table in use
52 $tables[] = array('Name' => $tmp[0]);
55 mysql_free_result($result);
56 $sot_ready = TRUE;
61 if (!isset($sot_ready)) {
62 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
63 $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
64 if ($result != FALSE && mysql_num_rows($result) > 0) {
65 while ($sts_tmp = mysql_fetch_array($result)) {
66 $tables[] = $sts_tmp;
68 mysql_free_result($result);
71 $num_tables = (isset($tables) ? count($tables) : 0);
72 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
73 else {
74 $result = mysql_list_tables($db);
75 $num_tables = @mysql_numrows($result);
76 for ($i = 0; $i < $num_tables; $i++) {
77 $tables[] = mysql_tablename($result, $i);
79 mysql_free_result($result);
83 /**
84 * If there is at least one table, displays the printer friendly view, else
85 * an error message
87 // 1. No table
88 if ($num_tables == 0) {
89 echo $strNoTablesFound;
91 // 2. Shows table informations on mysql >= 3.23 - staybyte - 11 June 2001
92 else if (PMA_MYSQL_INT_VERSION >= 32300) {
95 <!-- The tables list -->
96 <table border="<?php echo $cfgBorder; ?>">
97 <tr>
98 <th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
99 <th><?php echo ucfirst($strRecords); ?></th>
100 <th><?php echo ucfirst($strType); ?></th>
101 <?php
102 if ($cfgShowStats) {
103 echo '<th>' . ucfirst($strSize) . '</th>';
105 echo "\n";
107 </tr>
108 <?php
109 $i = $sum_entries = $sum_size = 0;
110 while (list($keyname, $sts_data) = each($tables)) {
111 $table = $sts_data['Name'];
112 $bgcolor = ($i++ % 2) ? $cfgBgcolorOne : $cfgBgcolorTwo;
113 echo "\n";
115 <tr>
116 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
117 &nbsp;<b><?php echo htmlspecialchars($table); ?>&nbsp;</b>&nbsp;
118 </td>
119 <?php
120 echo "\n";
121 $mergetable = FALSE;
122 $nonisam = FALSE;
123 if (isset($sts_data['Type'])) {
124 if ($sts_data['Type'] == 'MRG_MyISAM') {
125 $mergetable = TRUE;
126 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
127 $nonisam = TRUE;
131 if (isset($sts_data['Rows'])) {
132 if ($mergetable == FALSE) {
133 if ($cfgShowStats && $nonisam == FALSE) {
134 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
135 $sum_size += $tblsize;
136 if ($tblsize > 0) {
137 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
138 } else {
139 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
141 } else if ($cfgShowStats) {
142 $formated_size = '&nbsp;-&nbsp;';
143 $unit = '';
145 $sum_entries += $sts_data['Rows'];
147 // MyISAM MERGE Table
148 else if ($cfgShowStats && $mergetable == TRUE) {
149 $formated_size = '&nbsp;-&nbsp;';
150 $unit = '';
152 else if ($cfgShowStats) {
153 $formated_size = 'unknown';
154 $unit = '';
157 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
158 <?php
159 echo "\n" . ' ';
160 if ($mergetable == TRUE) {
161 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
162 } else {
163 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
166 </td>
167 <td nowrap="nowrap" bgcolor="<?php echo $bgcolor; ?>">
168 &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
169 </td>
170 <?php
171 if ($cfgShowStats) {
172 echo "\n";
174 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
175 &nbsp;<?php echo $formated_size . ' ' . $unit . "\n"; ?>
176 </td>
177 <?php
178 echo "\n";
179 } // end if
180 } else {
182 <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
183 <?php echo $strInUse . "\n"; ?>
184 </td>
185 <?php
187 echo "\n";
189 </tr>
190 <?php
192 // Show Summary
193 if ($cfgShowStats) {
194 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
196 echo "\n";
198 <tr>
199 <th align="center">
200 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
201 </th>
202 <th align="right" nowrap="nowrap">
203 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
204 </th>
205 <th align="center">
206 <b>--</b>
207 </th>
208 <?php
209 if ($cfgShowStats) {
210 echo "\n";
212 <th align="right" nowrap="nowrap">
213 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
214 </th>
215 <?php
217 echo "\n";
219 </tr>
220 </table>
221 <?php
222 } // end case mysql >= 3.23
224 // 3. Shows tables list mysql < 3.23
225 else {
226 $i = 0;
227 echo "\n";
230 <!-- The tables list -->
231 <table border="<?php echo $cfgBorder; ?>">
232 <tr>
233 <th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
234 <th><?php echo ucfirst($strRecords); ?></th>
235 </tr>
236 <?php
237 while ($i < $num_tables) {
238 $bgcolor = ($i % 2) ? $cfgBgcolorOne : $bgcolor = $cfgBgcolorTwo;
239 echo "\n";
241 <tr>
242 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
243 <b><?php echo htmlspecialchars($tables[$i]); ?>&nbsp;</b>
244 </td>
245 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
246 &nbsp;<?php PMA_countRecords($db, $tables[$i]); ?>
247 </td>
248 </tr>
249 <?php
250 $i++;
251 } // end while
252 echo "\n";
254 </table>
255 <?php
256 } // end if
260 * Displays the footer
262 echo "\n";
263 require('./footer.inc.php3');