00001 <?php
00002
00003
00004
00008 if (!isset($selected_tbl)) {
00009 require_once('./libraries/grab_globals.lib.php');
00010 require_once('./header.inc.php');
00011 }
00012
00013
00014
00015 if (!isset($the_tables) || !is_array($the_tables)) {
00016 $the_tables = array();
00017 }
00018
00022 require_once('./libraries/relation.lib.php');
00023 require_once('./libraries/transformations.lib.php');
00024
00025 $cfgRelation = PMA_getRelationsParam();
00026
00027
00031 if (isset($table)) {
00032 $err_url = 'tbl_properties.php?' . PMA_generate_common_url($db, $table);
00033 } else {
00034 $err_url = 'db_details.php?' . PMA_generate_common_url($db);
00035 }
00036
00037
00041 PMA_mysql_select_db($db);
00042
00043
00048 if (isset($selected_tbl) && is_array($selected_tbl)) {
00049 $the_tables = $selected_tbl;
00050 } else if (isset($table)) {
00051 $the_tables[] = $table;
00052 }
00053 $multi_tables = (count($the_tables) > 1);
00054
00055 if ($multi_tables) {
00056 $tbl_list = '';
00057 foreach($the_tables AS $key => $table) {
00058 $tbl_list .= (empty($tbl_list) ? '' : ', ')
00059 . PMA_backquote(urldecode($table));
00060 }
00061 echo '<b>'. $strShowTables . ' : ' . $tbl_list . '</b>' . "\n";
00062 echo '<hr />' . "\n";
00063 }
00064
00065 $tables_cnt = count($the_tables);
00066 $counter = 0;
00067
00068 foreach($the_tables AS $key => $table) {
00069 $table = urldecode($table);
00070 if ($counter + 1 >= $tables_cnt) {
00071 $breakstyle = '';
00072 } else {
00073 $breakstyle = ' style="page-break-after: always;"';
00074 }
00075 $counter++;
00076 echo '<div' . $breakstyle . '>' . "\n";
00077 echo '<h1>' . $table . '</h1>' . "\n";
00078
00082 $local_query = 'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'';
00083 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
00084 $showtable = PMA_mysql_fetch_array($result);
00085 $num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
00086 $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : '');
00087 if ($result) {
00088 mysql_free_result($result);
00089 }
00090
00091
00095 $local_query = 'SHOW KEYS FROM ' . PMA_backquote($table);
00096 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
00097 $primary = '';
00098 $indexes = array();
00099 $lastIndex = '';
00100 $indexes_info = array();
00101 $indexes_data = array();
00102 $pk_array = array();
00103
00104 while ($row = PMA_mysql_fetch_array($result)) {
00105
00106 if ($row['Key_name'] == 'PRIMARY') {
00107 $primary .= $row['Column_name'] . ', ';
00108 $pk_array[$row['Column_name']] = 1;
00109 }
00110
00111 if ($row['Key_name'] != $lastIndex ){
00112 $indexes[] = $row['Key_name'];
00113 $lastIndex = $row['Key_name'];
00114 }
00115 $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
00116 $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
00117 if (isset($row['Cardinality'])) {
00118 $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
00119 }
00120
00121
00122 $indexes_info[$row['Key_name']]['Comment'] = $row['Comment'];
00123
00124 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
00125 if (isset($row['Sub_part'])) {
00126 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
00127 }
00128
00129 }
00130 if ($result) {
00131 mysql_free_result($result);
00132 }
00133
00134
00138 $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table);
00139 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
00140 $fields_cnt = mysql_num_rows($result);
00141
00142
00143 if (!empty($cfgRelation['relation'])) {
00144
00145
00146 $res_rel = PMA_getForeigners($db, $table);
00147
00148 if (count($res_rel) > 0) {
00149 $have_rel = TRUE;
00150 } else {
00151 $have_rel = FALSE;
00152 }
00153 }
00154 else {
00155 $have_rel = FALSE;
00156 }
00157
00158
00162 if (!empty($show_comment)) {
00163 echo $strTableComments . ' : ' . $show_comment . '<br /><br />';
00164 }
00165
00169 ?>
00170
00171 <!-- TABLE INFORMATIONS -->
00172 <table width="95%" bordercolorlight="black" border="border" style="border-collapse: collapse; background-color: white">
00173 <tr>
00174 <th width="50"><?php echo $strField; ?></th>
00175 <th width="80"><?php echo $strType; ?></th>
00176 <!--<th width="50"><?php echo $strAttr; ?></th>-->
00177 <th width="40"><?php echo $strNull; ?></th>
00178 <th width="70"><?php echo $strDefault; ?></th>
00179 <!--<th width="50"><?php echo $strExtra; ?></th>-->
00180 <?php
00181 echo "\n";
00182 if ($have_rel) {
00183 echo ' <th>' . $strLinksTo . '</th>' . "\n";
00184 }
00185 if ($cfgRelation['commwork']) {
00186 echo ' <th>' . $strComments . '</th>' . "\n";
00187 }
00188 if ($cfgRelation['mimework']) {
00189 echo ' <th>MIME</th>' . "\n";
00190 }
00191 ?>
00192 </tr>
00193
00194 <?php
00195 $i = 0;
00196 while ($row = PMA_mysql_fetch_array($result)) {
00197 $bgcolor = ($i % 2) ?$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
00198 $i++;
00199
00200 $type = $row['Type'];
00201
00202
00203 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
00204 $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
00205 $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
00206 $type_nowrap = '';
00207
00208 $binary = 0;
00209 $unsigned = 0;
00210 $zerofill = 0;
00211 } else {
00212 $type_nowrap = ' nowrap="nowrap"';
00213 $type = preg_replace('@BINARY@i', '', $type);
00214 $type = preg_replace('@ZEROFILL@i', '', $type);
00215 $type = preg_replace('@UNSIGNED@i', '', $type);
00216 if (empty($type)) {
00217 $type = ' ';
00218 }
00219
00220 $binary = stristr($row['Type'], 'binary');
00221 $unsigned = stristr($row['Type'], 'unsigned');
00222 $zerofill = stristr($row['Type'], 'zerofill');
00223 }
00224 $strAttribute = ' ';
00225 if ($binary) {
00226 $strAttribute = 'BINARY';
00227 }
00228 if ($unsigned) {
00229 $strAttribute = 'UNSIGNED';
00230 }
00231 if ($zerofill) {
00232 $strAttribute = 'UNSIGNED ZEROFILL';
00233 }
00234 if (!isset($row['Default'])) {
00235 if ($row['Null'] != '') {
00236 $row['Default'] = '<i>NULL</i>';
00237 }
00238 } else {
00239 $row['Default'] = htmlspecialchars($row['Default']);
00240 }
00241 $field_name = htmlspecialchars($row['Field']);
00242 echo "\n";
00243 ?>
00244 <tr>
00245 <td width="50" class="print" nowrap="nowrap">
00246 <?php
00247 if (isset($pk_array[$row['Field']])) {
00248 echo ' <u>' . $field_name . '</u> ' . "\n";
00249 } else {
00250 echo ' ' . $field_name . ' ' . "\n";
00251 }
00252 ?>
00253 </td>
00254 <td width="80" class="print"<?php echo $type_nowrap; ?>><?php echo $type; ?><bdo dir="ltr"></bdo></td>
00255 <!--<td width="50" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $strAttribute; ?></td>-->
00256 <td width="40" class="print"><?php echo (($row['Null'] == '') ? $strNo : $strYes); ?> </td>
00257 <td width="70" class="print" nowrap="nowrap"><?php if (isset($row['Default'])) echo $row['Default']; ?> </td>
00258 <!--<td width="50" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $row['Extra']; ?> </td>-->
00259 <?php
00260 echo "\n";
00261 if ($have_rel) {
00262 echo ' <td class="print">';
00263 if (isset($res_rel[$field_name])) {
00264 echo htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'] );
00265 }
00266 echo ' </td>' . "\n";
00267 }
00268 if ($cfgRelation['commwork']) {
00269 echo ' <td class="print">';
00270 $comments = PMA_getComments($db, $table);
00271 if (isset($comments[$field_name])) {
00272 echo htmlspecialchars($comments[$field_name]);
00273 }
00274 echo ' </td>' . "\n";
00275 }
00276 if ($cfgRelation['mimework']) {
00277 $mime_map = PMA_getMIME($db, $table, true);
00278
00279 echo ' <td class="print">';
00280 if (isset($mime_map[$field_name])) {
00281 echo htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype']));
00282 }
00283 echo ' </td>' . "\n";
00284 }
00285 ?>
00286 </tr>
00287 <?php
00288 }
00289 mysql_free_result($result);
00290
00291 echo "\n";
00292 ?>
00293 </table>
00294
00295
00296 <?php
00300 $index_count = (isset($indexes))
00301 ? count($indexes)
00302 : 0;
00303 if ($index_count > 0) {
00304 echo "\n";
00305 ?>
00306 <br /><br />
00307
00308 <!-- Indexes -->
00309 <big><?php echo $strIndexes . ' :'; ?></big>
00310 <table bordercolorlight="black" border="border" style="border-collapse: collapse; background-color: white">
00311 <tr>
00312 <th><?php echo $strKeyname; ?></th>
00313 <th><?php echo $strType; ?></th>
00314 <th><?php echo $strCardinality; ?></th>
00315 <th colspan="2"><?php echo $strField; ?></th>
00316 </tr>
00317 <?php
00318 echo "\n";
00319 foreach($indexes AS $index_no => $index_name) {
00320 $cell_bgd = (($index_no % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']);
00321 $index_td = ' <td class="print" rowspan="' . count($indexes_info[$index_name]['Sequences']) . '">' . "\n";
00322 echo ' <tr>' . "\n";
00323 echo $index_td
00324 . ' ' . htmlspecialchars($index_name) . "\n"
00325 . ' </td>' . "\n";
00326
00327 if ($indexes_info[$index_name]['Comment'] == 'FULLTEXT') {
00328 $index_type = 'FULLTEXT';
00329 } else if ($index_name == 'PRIMARY') {
00330 $index_type = 'PRIMARY';
00331 } else if ($indexes_info[$index_name]['Non_unique'] == '0') {
00332 $index_type = 'UNIQUE';
00333 } else {
00334 $index_type = 'INDEX';
00335 }
00336 echo $index_td
00337 . ' ' . $index_type . "\n"
00338 . ' </td>' . "\n";
00339
00340 echo $index_td
00341 . ' ' . (isset($indexes_info[$index_name]['Cardinality']) ? $indexes_info[$index_name]['Cardinality'] : $strNone) . "\n"
00342 . ' </td>' . "\n";
00343
00344 foreach($indexes_info[$index_name]['Sequences'] AS $row_no => $seq_index) {
00345 if ($row_no > 0) {
00346 echo ' <tr>' . "\n";
00347 }
00348 if (!empty($indexes_data[$index_name][$seq_index]['Sub_part'])) {
00349 echo ' <td class="print">' . "\n"
00350 . ' ' . $indexes_data[$index_name][$seq_index]['Column_name'] . "\n"
00351 . ' </td>' . "\n";
00352 echo ' <td align="right" class="print">' . "\n"
00353 . ' ' . $indexes_data[$index_name][$seq_index]['Sub_part'] . "\n"
00354 . ' </td>' . "\n";
00355 echo ' </tr>' . "\n";
00356 } else {
00357 echo ' <td class="print" colspan="2">' . "\n"
00358 . ' ' . $indexes_data[$index_name][$seq_index]['Column_name'] . "\n"
00359 . ' </td>' . "\n";
00360 echo ' </tr>' . "\n";
00361 }
00362 }
00363 }
00364 echo "\n";
00365 ?>
00366 </table>
00367 <?php
00368 echo "\n";
00369 }
00370
00371
00377 if ($cfg['ShowStats']) {
00378 $nonisam = FALSE;
00379 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
00380 $nonisam = TRUE;
00381 }
00382 if ($nonisam == FALSE) {
00383
00384 $mergetable = FALSE;
00385 if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
00386 $mergetable = TRUE;
00387 }
00388 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length']);
00389 if ($mergetable == FALSE) {
00390 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length']);
00391 }
00392 if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
00393 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free']);
00394 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free']);
00395 } else {
00396 unset($free_size);
00397 unset($free_unit);
00398 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
00399 }
00400 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
00401 if ($num_rows > 0) {
00402 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
00403 }
00404
00405
00406 ?>
00407 <br /><br />
00408
00409 <table border="0" cellspacing="0" cellpadding="0">
00410 <tr>
00411
00412 <!-- Space usage -->
00413 <td class="print" valign="top">
00414 <big><?php echo $strSpaceUsage . ' :'; ?></big>
00415 <table width="100%" bordercolorlight="black" border="border" style="border-collapse: collapse; background-color: white">
00416 <tr>
00417 <th><?php echo $strType; ?></th>
00418 <th colspan="2" align="center"><?php echo $strUsage; ?></th>
00419 </tr>
00420 <tr>
00421 <td class="print" style="padding-right: 10px"><?php echo $strData; ?></td>
00422 <td align="right" class="print" nowrap="nowrap"><?php echo $data_size; ?></td>
00423 <td class="print"><?php echo $data_unit; ?></td>
00424 </tr>
00425 <?php
00426 if (isset($index_size)) {
00427 echo "\n";
00428 ?>
00429 <tr>
00430 <td class="print" style="padding-right: 10px"><?php echo $strIndex; ?></td>
00431 <td align="right" class="print" nowrap="nowrap"><?php echo $index_size; ?></td>
00432 <td class="print"><?php echo $index_unit; ?></td>
00433 </tr>
00434 <?php
00435 }
00436 if (isset($free_size)) {
00437 echo "\n";
00438 ?>
00439 <tr style="color: #bb0000">
00440 <td class="print" style="padding-right: 10px"><?php echo $strOverhead; ?></td>
00441 <td align="right" class="print" nowrap="nowrap"><?php echo $free_size; ?></td>
00442 <td class="print"><?php echo $free_unit; ?></td>
00443 </tr>
00444 <tr>
00445 <td class="print" style="padding-right: 10px"><?php echo $strEffective; ?></td>
00446 <td align="right" class="print" nowrap="nowrap"><?php echo $effect_size; ?></td>
00447 <td class="print"><?php echo $effect_unit; ?></td>
00448 </tr>
00449 <?php
00450 }
00451 if (isset($tot_size) && $mergetable == FALSE) {
00452 echo "\n";
00453 ?>
00454 <tr>
00455 <td class="print" style="padding-right: 10px"><?php echo $strTotalUC; ?></td>
00456 <td align="right" class="print" nowrap="nowrap"><?php echo $tot_size; ?></td>
00457 <td class="print"><?php echo $tot_unit; ?></td>
00458 </tr>
00459 <?php
00460 }
00461 echo "\n";
00462 ?>
00463 </table>
00464 </td>
00465
00466 <td width="20" class="print"> </td>
00467
00468 <!-- Rows Statistic -->
00469 <td valign="top">
00470 <big><?php echo $strRowsStatistic . ' :'; ?></big>
00471 <table width=100% bordercolorlight="black" border="border" style="border-collapse: collapse; background-color: white">
00472 <tr>
00473 <th><?php echo $strStatement; ?></th>
00474 <th align="center"><?php echo $strValue; ?></th>
00475 </tr>
00476 <?php
00477 $i = 0;
00478 if (isset($showtable['Row_format'])) {
00479 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
00480 echo "\n";
00481 ?>
00482 <tr>
00483 <td class="print"><?php echo ucfirst($strFormat); ?></td>
00484 <td align="<?php echo $cell_align_left; ?>" class="print" nowrap="nowrap">
00485 <?php
00486 echo ' ';
00487 if ($showtable['Row_format'] == 'Fixed') {
00488 echo $strFixed;
00489 } else if ($showtable['Row_format'] == 'Dynamic') {
00490 echo $strDynamic;
00491 } else {
00492 echo $showtable['Row_format'];
00493 }
00494 echo "\n";
00495 ?>
00496 </td>
00497 </tr>
00498 <?php
00499 }
00500 if (isset($showtable['Rows'])) {
00501 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
00502 echo "\n";
00503 ?>
00504 <tr>
00505 <td class="print"><?php echo ucfirst($strRows); ?></td>
00506 <td align="right" class="print" nowrap="nowrap">
00507 <?php echo number_format($showtable['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?>
00508 </td>
00509 </tr>
00510 <?php
00511 }
00512 if (isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
00513 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
00514 echo "\n";
00515 ?>
00516 <tr>
00517 <td class="print"><?php echo ucfirst($strRowLength); ?> ø</td>
00518 <td class="print" nowrap="nowrap">
00519 <?php echo number_format($showtable['Avg_row_length'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?>
00520 </td>
00521 </tr>
00522 <?php
00523 }
00524 if (isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == FALSE) {
00525 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
00526 echo "\n";
00527 ?>
00528 <tr>
00529 <td class="print"><?php echo ucfirst($strRowSize); ?> ø</td>
00530 <td align="right" class="print" nowrap="nowrap">
00531 <?php echo $avg_size . ' ' . $avg_unit . "\n"; ?>
00532 </td>
00533 </tr>
00534 <?php
00535 }
00536 if (isset($showtable['Auto_increment'])) {
00537 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
00538 echo "\n";
00539 ?>
00540 <tr>
00541 <td class="print"><?php echo ucfirst($strNext); ?> Autoindex</td>
00542 <td align="right" class="print" nowrap="nowrap">
00543 <?php echo number_format($showtable['Auto_increment'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?>
00544 </td>
00545 </tr>
00546 <?php
00547 }
00548 echo "\n";
00549
00550 if (isset($showtable['Create_time'])) {
00551 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
00552 echo "\n";
00553 ?>
00554 <tr>
00555 <td class="print"><?php echo $strStatCreateTime; ?></td>
00556 <td align="right" class="print" nowrap="nowrap">
00557 <?php echo PMA_localisedDate(strtotime($showtable['Create_time'])) . "\n"; ?>
00558 </td>
00559 </tr>
00560 <?php
00561 }
00562 echo "\n";
00563
00564 if (isset($showtable['Update_time'])) {
00565 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
00566 echo "\n";
00567 ?>
00568 <tr>
00569 <td class="print"><?php echo $strStatUpdateTime; ?></td>
00570 <td align="right" class="print" nowrap="nowrap">
00571 <?php echo PMA_localisedDate(strtotime($showtable['Update_time'])) . "\n"; ?>
00572 </td>
00573 </tr>
00574 <?php
00575 }
00576 echo "\n";
00577
00578 if (isset($showtable['Check_time'])) {
00579 $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
00580 echo "\n";
00581 ?>
00582 <tr>
00583 <td class="print"><?php echo $strStatCheckTime; ?></td>
00584 <td align="right" class="print" nowrap="nowrap">
00585 <?php echo PMA_localisedDate(strtotime($showtable['Check_time'])) . "\n"; ?>
00586 </td>
00587 </tr>
00588 <?php
00589 }
00590 echo "\n";
00591 ?>
00592 </table>
00593 </td>
00594 </tr>
00595 </table>
00596
00597 <?php
00598 }
00599 }
00600
00601 echo "\n";
00602 if ($multi_tables) {
00603 unset($ret_keys);
00604 unset($num_rows);
00605 unset($show_comment);
00606 echo '<hr />' . "\n";
00607 }
00608 echo '</div>' . "\n";
00609
00610 }
00611
00612
00613
00617 echo "\n";
00618 ?>
00619 <script type="text/javascript" language="javascript1.2">
00620 <!--
00621 function printPage()
00622 {
00623 document.getElementById('print').style.visibility = 'hidden';
00624
00625 if (typeof(window.print) != 'undefined') {
00626 window.print();
00627 }
00628 document.getElementById('print').style.visibility = '';
00629 }
00630
00631 </script>
00632 <?php
00633 echo '<br /><br /> <input type="button" style="visibility: ; width: 100px; height: 25px" id="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
00634
00635 require_once('./footer.inc.php');
00636 ?>