Documentation TYPO3 par Ameos |
00001 <?php 00002 /* $Id: db_datadict.php,v 2.17 2005/05/22 17:09:27 lem9 Exp $ */ 00003 00004 00008 if (!isset($selected_tbl)) { 00009 require_once('./libraries/grab_globals.lib.php'); 00010 require_once('./header.inc.php'); 00011 } 00012 00013 00017 require_once('./libraries/relation.lib.php'); 00018 require_once('./libraries/transformations.lib.php'); 00019 00020 $cfgRelation = PMA_getRelationsParam(); 00021 00025 PMA_checkParameters(array('db')); 00026 00030 if (isset($table)) { 00031 $err_url = 'tbl_properties.php?' . PMA_generate_common_url($db, $table); 00032 } else { 00033 $err_url = 'db_details.php?' . PMA_generate_common_url($db); 00034 } 00035 00036 if ($cfgRelation['commwork']) { 00037 $comment = PMA_getComments($db); 00038 00042 if (is_array($comment)) { 00043 ?> 00044 <!-- DB comment --> 00045 <p><?php echo $strDBComment; ?> <i> 00046 <?php echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?> 00047 </i></p> 00048 <?php 00049 } // end if 00050 } 00051 00055 PMA_DBI_select_db($db); 00056 $rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); 00057 00058 $count = 0; 00059 while ($row = PMA_DBI_fetch_assoc($rowset)) { 00060 $myfieldname = 'Tables_in_' . htmlspecialchars($db); 00061 $table = $row[$myfieldname]; 00062 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) { 00063 $comments = PMA_getComments($db, $table); 00064 } 00065 00066 if ($count != 0) { 00067 echo '<div style="page-break-before: always;">' . "\n"; 00068 } else { 00069 echo '<div>' . "\n"; 00070 } 00071 00072 echo '<h2>' . $table . '</h2>' . "\n"; 00073 00077 // The 'show table' statement works correct since 3.23.03 00078 $result = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'', NULL, PMA_DBI_QUERY_STORE); 00079 $showtable = PMA_DBI_fetch_assoc($result); 00080 $num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); 00081 $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); 00082 PMA_DBI_free_result($result); 00083 00084 00089 PMA_DBI_select_db($db); 00090 $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';'); 00091 $primary = ''; 00092 $indexes = array(); 00093 $lastIndex = ''; 00094 $indexes_info = array(); 00095 $indexes_data = array(); 00096 $pk_array = array(); // will be use to emphasis prim. keys in the table 00097 // view 00098 while ($row = PMA_DBI_fetch_assoc($result)) { 00099 // Backups the list of primary keys 00100 if ($row['Key_name'] == 'PRIMARY') { 00101 $primary .= $row['Column_name'] . ', '; 00102 $pk_array[$row['Column_name']] = 1; 00103 } 00104 // Retains keys informations 00105 if ($row['Key_name'] != $lastIndex ){ 00106 $indexes[] = $row['Key_name']; 00107 $lastIndex = $row['Key_name']; 00108 } 00109 $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index']; 00110 $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique']; 00111 if (isset($row['Cardinality'])) { 00112 $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality']; 00113 } 00114 // I don't know what does following column mean.... 00115 // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed']; 00116 00117 $indexes_info[$row['Key_name']]['Comment'] = $row['Comment']; 00118 00119 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name']; 00120 if (isset($row['Sub_part'])) { 00121 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part']; 00122 } 00123 00124 } // end while 00125 if ($result) { 00126 PMA_DBI_free_result($result); 00127 } 00128 00129 00133 $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE); 00134 $fields_cnt = PMA_DBI_num_rows($result); 00135 // Check if we can use Relations (Mike Beck) 00136 if (!empty($cfgRelation['relation'])) { 00137 // Find which tables are related with the current one and write it in 00138 // an array 00139 $res_rel = PMA_getForeigners($db, $table); 00140 00141 if (count($res_rel) > 0) { 00142 $have_rel = TRUE; 00143 } else { 00144 $have_rel = FALSE; 00145 } 00146 } 00147 else { 00148 $have_rel = FALSE; 00149 } // end if 00150 00151 00155 if (!empty($show_comment)) { 00156 echo $strTableComments . ': ' . $show_comment . '<br /><br />'; 00157 } 00158 00162 ?> 00163 00164 <!-- TABLE INFORMATIONS --> 00165 <table width="100%" style="border: 1px solid black; border-collapse: collapse; background-color: white;"> 00166 <tr> 00167 <th width="50"><?php echo $strField; ?></th> 00168 <th width="80"><?php echo $strType; ?></th> 00169 <!--<th width="50"><?php echo $strAttr; ?></th>--> 00170 <th width="40"><?php echo $strNull; ?></th> 00171 <th width="70"><?php echo $strDefault; ?></th> 00172 <!--<th width="50"><?php echo $strExtra; ?></th>--> 00173 <?php 00174 echo "\n"; 00175 if ($have_rel) { 00176 echo ' <th>' . $strLinksTo . '</th>' . "\n"; 00177 } 00178 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) { 00179 echo ' <th>' . $strComments . '</th>' . "\n"; 00180 } 00181 if ($cfgRelation['mimework']) { 00182 echo ' <th>MIME</th>' . "\n"; 00183 } 00184 ?> 00185 </tr> 00186 00187 <?php 00188 $i = 0; 00189 while ($row = PMA_DBI_fetch_assoc($result)) { 00190 $bgcolor = ($i % 2) ?$cfg['BgcolorOne'] : $cfg['BgcolorTwo']; 00191 $i++; 00192 00193 $type = $row['Type']; 00194 // reformat mysql query output - staybyte - 9. June 2001 00195 // loic1: set or enum types: slashes single quotes inside options 00196 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) { 00197 $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1); 00198 $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; 00199 $type_nowrap = ''; 00200 00201 $binary = 0; 00202 $unsigned = 0; 00203 $zerofill = 0; 00204 } else { 00205 $binary = stristr($row['Type'], 'binary'); 00206 $unsigned = stristr($row['Type'], 'unsigned'); 00207 $zerofill = stristr($row['Type'], 'zerofill'); 00208 $type_nowrap = ' nowrap="nowrap"'; 00209 $type = preg_replace('@BINARY@i', '', $type); 00210 $type = preg_replace('@ZEROFILL@i', '', $type); 00211 $type = preg_replace('@UNSIGNED@i', '', $type); 00212 if (empty($type)) { 00213 $type = ' '; 00214 } 00215 } 00216 $strAttribute = ' '; 00217 if ($binary) { 00218 $strAttribute = 'BINARY'; 00219 } 00220 if ($unsigned) { 00221 $strAttribute = 'UNSIGNED'; 00222 } 00223 if ($zerofill) { 00224 $strAttribute = 'UNSIGNED ZEROFILL'; 00225 } 00226 if (!isset($row['Default'])) { 00227 if ($row['Null'] != '') { 00228 $row['Default'] = '<i>NULL</i>'; 00229 } 00230 } else { 00231 $row['Default'] = htmlspecialchars($row['Default']); 00232 } 00233 $field_name = htmlspecialchars($row['Field']); 00234 echo "\n"; 00235 ?> 00236 <tr> 00237 <td width=50 class='print' nowrap="nowrap"> 00238 <?php 00239 echo "\n"; 00240 if (isset($pk_array[$row['Field']])) { 00241 echo ' <u>' . $field_name . '</u> ' . "\n"; 00242 } else { 00243 echo ' ' . $field_name . ' ' . "\n"; 00244 } 00245 ?> 00246 </td> 00247 <td width="80" class="print"<?php echo $type_nowrap; ?>><?php echo $type; ?><bdo dir="ltr"></bdo></td> 00248 <!--<td width="50" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $strAttribute; ?></td>--> 00249 <td width="40" class="print"><?php echo (($row['Null'] == '') ? $strNo : $strYes); ?> </td> 00250 <td width="70" class="print" nowrap="nowrap"><?php if (isset($row['Default'])) echo $row['Default']; ?> </td> 00251 <!--<td width="50" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $row['Extra']; ?> </td>--> 00252 <?php 00253 echo "\n"; 00254 if ($have_rel) { 00255 echo ' <td class="print">'; 00256 if (isset($res_rel[$field_name])) { 00257 echo htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field']); 00258 } 00259 echo ' </td>' . "\n"; 00260 } 00261 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) { 00262 echo ' <td class="print">'; 00263 if (isset($comments[$field_name])) { 00264 echo htmlspecialchars($comments[$field_name]); 00265 } 00266 echo ' </td>' . "\n"; 00267 } 00268 if ($cfgRelation['mimework']) { 00269 $mime_map = PMA_getMIME($db, $table, true); 00270 00271 echo ' <td class="print">'; 00272 if (isset($mime_map[$field_name])) { 00273 echo htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])); 00274 } 00275 echo ' </td>' . "\n"; 00276 } 00277 ?> 00278 </tr> 00279 <?php 00280 } // end while 00281 PMA_DBI_free_result($result); 00282 00283 echo "\n"; 00284 ?> 00285 </table> 00286 00287 <?php 00288 echo '</div>' . "\n"; 00289 00290 $count++; 00291 } //ends main while 00292 00293 00297 echo "\n"; 00298 ?> 00299 <script type="text/javascript" language="javascript1.2"> 00300 <!-- 00301 function printPage() 00302 { 00303 document.getElementById('print').style.visibility = 'hidden'; 00304 // Do print the page 00305 if (typeof(window.print) != 'undefined') { 00306 window.print(); 00307 } 00308 document.getElementById('print').style.visibility = ''; 00309 } 00310 //--> 00311 </script> 00312 <?php 00313 echo '<br /><br /> <input type="button" style="width: 100px; height: 25px;" id="print" value="' . $strPrint . '" onclick="printPage()" />' . "\n"; 00314 00315 require_once('./footer.inc.php'); 00316 ?>