4 require_once('./libraries/common.lib.php');
7 * Gets the variables sent or posted to this script, then displays headers
10 if (!isset($selected_tbl)) {
11 require_once('./header.inc.php');
16 if (!isset($the_tables) ||
!is_array($the_tables)) {
17 $the_tables = array();
21 * Gets the relations settings
23 require_once('./libraries/relation.lib.php');
24 require_once('./libraries/transformations.lib.php');
25 require_once('./libraries/tbl_indexes.lib.php');
27 $cfgRelation = PMA_getRelationsParam();
31 * Defines the url to return to in case of error in a sql statement
34 $err_url = 'tbl_properties.php?' . PMA_generate_common_url($db, $table);
36 $err_url = 'db_details.php?' . PMA_generate_common_url($db);
41 * Selects the database
43 PMA_DBI_select_db($db);
47 * Multi-tables printview thanks to Christophe Gesché from the "MySQL Form
48 * Generator for PHPMyAdmin" (http://sourceforge.net/projects/phpmysqlformgen/)
50 if (isset($selected_tbl) && is_array($selected_tbl)) {
51 $the_tables = $selected_tbl;
52 } else if (isset($table)) {
53 $the_tables[] = $table;
55 $multi_tables = (count($the_tables) > 1);
58 if (empty($GLOBALS['is_header_sent'])) {
59 require_once('./header.inc.php');
62 foreach ($the_tables AS $key => $table) {
63 $tbl_list .= (empty($tbl_list) ?
'' : ', ')
64 . PMA_backquote(urldecode($table));
66 echo '<b>'. $strShowTables . ': ' . $tbl_list . '</b>' . "\n";
70 $tables_cnt = count($the_tables);
73 foreach ($the_tables AS $key => $table) {
74 $table = urldecode($table);
75 if ($counter +
1 >= $tables_cnt) {
78 $breakstyle = ' style="page-break-after: always;"';
81 echo '<div' . $breakstyle . '>' . "\n";
82 echo '<h1>' . $table . '</h1>' . "\n";
85 * Gets table informations
87 $result = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';');
88 $showtable = PMA_DBI_fetch_assoc($result);
89 $num_rows = (isset($showtable['Rows']) ?
$showtable['Rows'] : 0);
90 $show_comment = (isset($showtable['Comment']) ?
$showtable['Comment'] : '');
91 PMA_DBI_free_result($result);
94 // Gets table keys and store them in arrays
96 $indexes_info = array();
97 $indexes_data = array();
98 $ret_keys = PMA_get_indexes($table, $err_url_0);
100 PMA_extract_indexes($ret_keys, $indexes, $indexes_info, $indexes_data);
103 * Gets fields properties
105 $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE
);
106 $fields_cnt = PMA_DBI_num_rows($result);
108 // Check if we can use Relations (Mike Beck)
109 if (!empty($cfgRelation['relation'])) {
110 // Find which tables are related with the current one and write it in
112 $res_rel = PMA_getForeigners($db, $table);
114 if (count($res_rel) > 0) {
126 * Displays the comments of the table if MySQL >= 3.23
128 if (!empty($show_comment)) {
129 echo $strTableComments . ': ' . $show_comment . '<br /><br />';
133 * Displays the table structure
137 <!-- TABLE INFORMATIONS
-->
138 <table width
="95%" bordercolorlight
="black" border
="border" style
="border-collapse: collapse; background-color: white">
140 <th width
="50"><?php
echo $strField; ?
></th
>
141 <th width
="80"><?php
echo $strType; ?
></th
>
142 <!--<th width
="50"><?php
echo $strAttr; ?
></th
>-->
143 <th width
="40"><?php
echo $strNull; ?
></th
>
144 <th width
="70"><?php
echo $strDefault; ?
></th
>
145 <!--<th width
="50"><?php
echo $strExtra; ?
></th
>-->
149 echo ' <th>' . $strLinksTo . '</th>' . "\n";
151 if ($cfgRelation['commwork']) {
152 echo ' <th>' . $strComments . '</th>' . "\n";
154 if ($cfgRelation['mimework']) {
155 echo ' <th>MIME</th>' . "\n";
162 while ($row = PMA_DBI_fetch_assoc($result)) {
163 $bgcolor = ($i %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
166 $type = $row['Type'];
167 // reformat mysql query output - staybyte - 9. June 2001
168 // loic1: set or enum types: slashes single quotes inside options
169 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
170 $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
171 $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
178 $type_nowrap = ' nowrap="nowrap"';
179 $type = preg_replace('@BINARY@i', '', $type);
180 $type = preg_replace('@ZEROFILL@i', '', $type);
181 $type = preg_replace('@UNSIGNED@i', '', $type);
186 $binary = stristr($row['Type'], 'binary');
187 $unsigned = stristr($row['Type'], 'unsigned');
188 $zerofill = stristr($row['Type'], 'zerofill');
190 $strAttribute = ' ';
192 $strAttribute = 'BINARY';
195 $strAttribute = 'UNSIGNED';
198 $strAttribute = 'UNSIGNED ZEROFILL';
200 if (!isset($row['Default'])) {
201 if ($row['Null'] != '') {
202 $row['Default'] = '<i>NULL</i>';
205 $row['Default'] = htmlspecialchars($row['Default']);
207 $field_name = htmlspecialchars($row['Field']);
211 <td width
="50" class="print" nowrap
="nowrap">
213 if (isset($pk_array[$row['Field']])) {
214 echo ' <u>' . $field_name . '</u> ' . "\n";
216 echo ' ' . $field_name . ' ' . "\n";
220 <td width
="80" class="print"<?php
echo $type_nowrap; ?
>><?php
echo $type; ?
><bdo dir
="ltr"></bdo
></td
>
221 <!--<td width
="50" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap"><?php
echo $strAttribute; ?
></td
>-->
222 <td width
="40" class="print"><?php
echo (($row['Null'] == '') ?
$strNo : $strYes); ?
> 
;</td
>
223 <td width
="70" class="print" nowrap
="nowrap"><?php
if (isset($row['Default'])) echo $row['Default']; ?
> 
;</td
>
224 <!--<td width
="50" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap"><?php
echo $row['Extra']; ?
> 
;</td
>-->
228 echo ' <td class="print">';
229 if (isset($res_rel[$field_name])) {
230 echo htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'] );
232 echo ' </td>' . "\n";
234 if ($cfgRelation['commwork']) {
235 echo ' <td class="print">';
236 $comments = PMA_getComments($db, $table);
237 if (isset($comments[$field_name])) {
238 echo htmlspecialchars($comments[$field_name]);
240 echo ' </td>' . "\n";
242 if ($cfgRelation['mimework']) {
243 $mime_map = PMA_getMIME($db, $table, true);
245 echo ' <td class="print">';
246 if (isset($mime_map[$field_name])) {
247 echo htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype']));
249 echo ' </td>' . "\n";
255 PMA_DBI_free_result($result);
265 && ( $db != 'information_schema'
266 || PMA_MYSQL_INT_VERSION
< 50002 ) ) {
271 $index_count = (isset($indexes))
274 if ($index_count > 0) {
280  
;<big
><?php
echo $strIndexes . ':'; ?
></big
>
281 <table bordercolorlight
="black" border
="border" style
="border-collapse: collapse; background-color: white">
283 <th
><?php
echo $strKeyname; ?
></th
>
284 <th
><?php
echo $strType; ?
></th
>
285 <th
><?php
echo $strCardinality; ?
></th
>
286 <th colspan
="2"><?php
echo $strField; ?
></th
>
290 PMA_show_indexes($table, $indexes, $indexes_info, $indexes_data, true, true);
296 } // end display indexes
300 * Displays Space usage and row statistics
302 * staybyte - 9 June 2001
304 if ($cfg['ShowStats']) {
306 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
309 if ($nonisam == FALSE) {
312 if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
315 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length']);
316 if ($mergetable == FALSE) {
317 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length']);
319 if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
320 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free']);
321 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'] - $showtable['Data_free']);
325 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length']);
327 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length']);
329 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] +
$showtable['Index_length']) / $showtable['Rows'], 6, 1);
336 <table border
="0" cellspacing
="0" cellpadding
="0" class="noborder">
340 <td
class="print" valign
="top">
341  
;<big
><?php
echo $strSpaceUsage . ':'; ?
></big
>
342 <table width
="100%" bordercolorlight
="black" border
="border" style
="border-collapse: collapse; background-color: white">
344 <th
><?php
echo $strType; ?
></th
>
345 <th colspan
="2" align
="center"><?php
echo $strUsage; ?
></th
>
348 <td
class="print" style
="padding-right: 10px"><?php
echo $strData; ?
></td
>
349 <td align
="right" class="print" nowrap
="nowrap"><?php
echo $data_size; ?
></td
>
350 <td
class="print"><?php
echo $data_unit; ?
></td
>
353 if (isset($index_size)) {
357 <td
class="print" style
="padding-right: 10px"><?php
echo $strIndex; ?
></td
>
358 <td align
="right" class="print" nowrap
="nowrap"><?php
echo $index_size; ?
></td
>
359 <td
class="print"><?php
echo $index_unit; ?
></td
>
363 if (isset($free_size)) {
366 <tr style
="color: #bb0000">
367 <td
class="print" style
="padding-right: 10px"><?php
echo $strOverhead; ?
></td
>
368 <td align
="right" class="print" nowrap
="nowrap"><?php
echo $free_size; ?
></td
>
369 <td
class="print"><?php
echo $free_unit; ?
></td
>
372 <td
class="print" style
="padding-right: 10px"><?php
echo $strEffective; ?
></td
>
373 <td align
="right" class="print" nowrap
="nowrap"><?php
echo $effect_size; ?
></td
>
374 <td
class="print"><?php
echo $effect_unit; ?
></td
>
378 if (isset($tot_size) && $mergetable == FALSE) {
382 <td
class="print" style
="padding-right: 10px"><?php
echo $strTotalUC; ?
></td
>
383 <td align
="right" class="print" nowrap
="nowrap"><?php
echo $tot_size; ?
></td
>
384 <td
class="print"><?php
echo $tot_unit; ?
></td
>
393 <td width
="20" class="print"> 
;</td
>
395 <!-- Rows Statistic
-->
397  
;<big
><?php
echo $strRowsStatistic . ':'; ?
></big
>
398 <table width
=100% bordercolorlight
="black" border
="border" style
="border-collapse: collapse; background-color: white">
400 <th
><?php
echo $strStatement; ?
></th
>
401 <th align
="center"><?php
echo $strValue; ?
></th
>
405 if (isset($showtable['Row_format'])) {
406 $bgcolor = ((++
$i%2
) ?
$cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
410 <td
class="print"><?php
echo ucfirst($strFormat); ?
></td
>
411 <td align
="<?php echo $cell_align_left; ?>" class="print" nowrap
="nowrap">
414 if ($showtable['Row_format'] == 'Fixed') {
416 } else if ($showtable['Row_format'] == 'Dynamic') {
419 echo $showtable['Row_format'];
427 if (isset($showtable['Rows'])) {
428 $bgcolor = ((++
$i%2
) ?
$cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
432 <td
class="print"><?php
echo ucfirst($strRows); ?
></td
>
433 <td align
="right" class="print" nowrap
="nowrap">
434 <?php
echo number_format($showtable['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?
>
439 if (isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
440 $bgcolor = ((++
$i%2
) ?
$cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
444 <td
class="print"><?php
echo ucfirst($strRowLength); ?
> 
;ø
;</td
>
445 <td
class="print" nowrap
="nowrap">
446 <?php
echo number_format($showtable['Avg_row_length'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?
>
451 if (isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == FALSE) {
452 $bgcolor = ((++
$i%2
) ?
$cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
456 <td
class="print"><?php
echo ucfirst($strRowSize); ?
> 
;ø
;</td
>
457 <td align
="right" class="print" nowrap
="nowrap">
458 <?php
echo $avg_size . ' ' . $avg_unit . "\n"; ?
>
463 if (isset($showtable['Auto_increment'])) {
464 $bgcolor = ((++
$i%2
) ?
$cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
468 <td
class="print"><?php
echo ucfirst($strNext); ?
> 
;Autoindex
</td
>
469 <td align
="right" class="print" nowrap
="nowrap">
470 <?php
echo number_format($showtable['Auto_increment'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?
>
477 if (isset($showtable['Create_time'])) {
478 $bgcolor = ((++
$i%2
) ?
$cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
482 <td
class="print"><?php
echo $strStatCreateTime; ?
></td
>
483 <td align
="right" class="print" nowrap
="nowrap">
484 <?php
echo PMA_localisedDate(strtotime($showtable['Create_time'])) . "\n"; ?
>
491 if (isset($showtable['Update_time'])) {
492 $bgcolor = ((++
$i%2
) ?
$cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
496 <td
class="print"><?php
echo $strStatUpdateTime; ?
></td
>
497 <td align
="right" class="print" nowrap
="nowrap">
498 <?php
echo PMA_localisedDate(strtotime($showtable['Update_time'])) . "\n"; ?
>
505 if (isset($showtable['Check_time'])) {
506 $bgcolor = ((++
$i%2
) ?
$cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
510 <td
class="print"><?php
echo $strStatCheckTime; ?
></td
>
511 <td align
="right" class="print" nowrap
="nowrap">
512 <?php
echo PMA_localisedDate(strtotime($showtable['Check_time'])) . "\n"; ?
>
525 } // end if ($nonisam == FALSE)
526 } // end if ($cfg['ShowStats'])
532 unset($show_comment);
533 echo '<hr />' . "\n";
535 echo '</div>' . "\n";
542 * Displays the footer
546 <script type
="text/javascript" language
="javascript1.2">
551 if (typeof(window
.print) != 'undefined') {
558 echo '<br /><br /> <input type="button" class="print_ignore" style="width: 100px; height: 25px" id="print" value="' . $strPrint . '" onclick="printPage()" />' . "\n";
560 require_once('./footer.inc.php');