6 * Gets the variables sent or posted to this script, then displays headers
8 if (!isset($selected_tbl)) {
9 require_once('./libraries/grab_globals.lib.php');
10 require_once('./header.inc.php');
15 * Gets the relations settings
17 require_once('./libraries/relation.lib.php');
18 require_once('./libraries/transformations.lib.php');
20 $cfgRelation = PMA_getRelationsParam();
25 PMA_checkParameters(array('db'));
28 * Defines the url to return to in case of error in a sql statement
31 $err_url = 'tbl_properties.php?' . PMA_generate_common_url($db, $table);
33 $err_url = 'db_details.php?' . PMA_generate_common_url($db);
36 if ($cfgRelation['commwork']) {
37 $comment = PMA_getComments($db);
42 if (is_array($comment)) {
45 <p
><?php
echo $strDBComment; ?
> <i
>
46 <?php
echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?
>
53 * Selects the database and gets tables names
55 PMA_DBI_select_db($db);
56 $rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE
);
59 while ($row = PMA_DBI_fetch_assoc($rowset)) {
60 $myfieldname = 'Tables_in_' . htmlspecialchars($db);
61 $table = $row[$myfieldname];
62 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION
>= 40100) {
63 $comments = PMA_getComments($db, $table);
67 echo '<div style="page-break-before: always;">' . "\n";
72 echo '<h2>' . $table . '</h2>' . "\n";
75 * Gets table informations
77 // The 'show table' statement works correct since 3.23.03
78 $result = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'', NULL, PMA_DBI_QUERY_STORE
);
79 $showtable = PMA_DBI_fetch_assoc($result);
80 $num_rows = (isset($showtable['Rows']) ?
$showtable['Rows'] : 0);
81 $show_comment = (isset($showtable['Comment']) ?
$showtable['Comment'] : '');
82 PMA_DBI_free_result($result);
86 * Gets table keys and retains them
89 PMA_DBI_select_db($db);
90 $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
94 $indexes_info = array();
95 $indexes_data = array();
96 $pk_array = array(); // will be use to emphasis prim. keys in the table
98 while ($row = PMA_DBI_fetch_assoc($result)) {
99 // Backups the list of primary keys
100 if ($row['Key_name'] == 'PRIMARY') {
101 $primary .= $row['Column_name'] . ', ';
102 $pk_array[$row['Column_name']] = 1;
104 // Retains keys informations
105 if ($row['Key_name'] != $lastIndex ){
106 $indexes[] = $row['Key_name'];
107 $lastIndex = $row['Key_name'];
109 $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
110 $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
111 if (isset($row['Cardinality'])) {
112 $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
114 // I don't know what does following column mean....
115 // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed'];
117 $indexes_info[$row['Key_name']]['Comment'] = $row['Comment'];
119 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
120 if (isset($row['Sub_part'])) {
121 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
126 PMA_DBI_free_result($result);
131 * Gets fields properties
133 $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE
);
134 $fields_cnt = PMA_DBI_num_rows($result);
135 // Check if we can use Relations (Mike Beck)
136 if (!empty($cfgRelation['relation'])) {
137 // Find which tables are related with the current one and write it in
139 $res_rel = PMA_getForeigners($db, $table);
141 if (count($res_rel) > 0) {
153 * Displays the comments of the table if MySQL >= 3.23
155 if (!empty($show_comment)) {
156 echo $strTableComments . ': ' . $show_comment . '<br /><br />';
160 * Displays the table structure
164 <!-- TABLE INFORMATIONS
-->
165 <table width
="100%" style
="border: 1px solid black; border-collapse: collapse; background-color: white;">
167 <th width
="50"><?php
echo $strField; ?
></th
>
168 <th width
="80"><?php
echo $strType; ?
></th
>
169 <!--<th width
="50"><?php
echo $strAttr; ?
></th
>-->
170 <th width
="40"><?php
echo $strNull; ?
></th
>
171 <th width
="70"><?php
echo $strDefault; ?
></th
>
172 <!--<th width
="50"><?php
echo $strExtra; ?
></th
>-->
176 echo ' <th>' . $strLinksTo . '</th>' . "\n";
178 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION
>= 40100) {
179 echo ' <th>' . $strComments . '</th>' . "\n";
181 if ($cfgRelation['mimework']) {
182 echo ' <th>MIME</th>' . "\n";
189 while ($row = PMA_DBI_fetch_assoc($result)) {
190 $bgcolor = ($i %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
193 $type = $row['Type'];
194 // reformat mysql query output - staybyte - 9. June 2001
195 // loic1: set or enum types: slashes single quotes inside options
196 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
197 $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
198 $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
205 $binary = stristr($row['Type'], 'binary');
206 $unsigned = stristr($row['Type'], 'unsigned');
207 $zerofill = stristr($row['Type'], 'zerofill');
208 $type_nowrap = ' nowrap="nowrap"';
209 $type = preg_replace('@BINARY@i', '', $type);
210 $type = preg_replace('@ZEROFILL@i', '', $type);
211 $type = preg_replace('@UNSIGNED@i', '', $type);
216 $strAttribute = ' ';
218 $strAttribute = 'BINARY';
221 $strAttribute = 'UNSIGNED';
224 $strAttribute = 'UNSIGNED ZEROFILL';
226 if (!isset($row['Default'])) {
227 if ($row['Null'] != '') {
228 $row['Default'] = '<i>NULL</i>';
231 $row['Default'] = htmlspecialchars($row['Default']);
233 $field_name = htmlspecialchars($row['Field']);
237 <td width
=50 class='print' nowrap
="nowrap">
240 if (isset($pk_array[$row['Field']])) {
241 echo ' <u>' . $field_name . '</u> ' . "\n";
243 echo ' ' . $field_name . ' ' . "\n";
247 <td width
="80" class="print"<?php
echo $type_nowrap; ?
>><?php
echo $type; ?
><bdo dir
="ltr"></bdo
></td
>
248 <!--<td width
="50" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap"><?php
echo $strAttribute; ?
></td
>-->
249 <td width
="40" class="print"><?php
echo (($row['Null'] == '') ?
$strNo : $strYes); ?
> 
;</td
>
250 <td width
="70" class="print" nowrap
="nowrap"><?php
if (isset($row['Default'])) echo $row['Default']; ?
> 
;</td
>
251 <!--<td width
="50" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap"><?php
echo $row['Extra']; ?
> 
;</td
>-->
255 echo ' <td class="print">';
256 if (isset($res_rel[$field_name])) {
257 echo htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field']);
259 echo ' </td>' . "\n";
261 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION
>= 40100) {
262 echo ' <td class="print">';
263 if (isset($comments[$field_name])) {
264 echo htmlspecialchars($comments[$field_name]);
266 echo ' </td>' . "\n";
268 if ($cfgRelation['mimework']) {
269 $mime_map = PMA_getMIME($db, $table, true);
271 echo ' <td class="print">';
272 if (isset($mime_map[$field_name])) {
273 echo htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype']));
275 echo ' </td>' . "\n";
281 PMA_DBI_free_result($result);
288 echo '</div>' . "\n";
295 * Displays the footer
299 <script type
="text/javascript" language
="javascript1.2">
303 document
.getElementById('print').style
.visibility
= 'hidden';
305 if (typeof(window
.print) != 'undefined') {
308 document
.getElementById('print').style
.visibility
= '';
313 echo '<br /><br /> <input type="button" style="width: 100px; height: 25px;" id="print" value="' . $strPrint . '" onclick="printPage()" />' . "\n";
315 require_once('./footer.inc.php');