2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Renders data dictionary
10 * Gets the variables sent or posted to this script, then displays headers
12 require_once 'libraries/common.inc.php';
14 if (! isset($selected_tbl)) {
15 include 'libraries/db_common.inc.php';
16 include 'libraries/db_info.inc.php';
19 $response = PMA_Response
::getInstance();
20 $header = $response->getHeader();
21 $header->enablePrintView();
24 * Gets the relations settings
26 $cfgRelation = PMA_getRelationsParam();
28 require_once 'libraries/transformations.lib.php';
29 require_once 'libraries/Index.class.php';
34 PMA_Util
::checkParameters(array('db'));
37 * Defines the url to return to in case of error in a sql statement
39 $err_url = 'db_sql.php' . PMA_URL_getCommon(array('db' => $db));
41 if ($cfgRelation['commwork']) {
42 $comment = PMA_getDbComment($db);
48 echo '<p>' . __('Database comment:')
49 . ' <i>' . htmlspecialchars($comment) . '</i></p>';
54 * Selects the database and gets tables names
56 $GLOBALS['dbi']->selectDb($db);
57 $tables = $GLOBALS['dbi']->getTables($db);
60 foreach ($tables as $table) {
61 $comments = PMA_getComments($db, $table);
65 echo '<h2>' . htmlspecialchars($table) . '</h2>' . "\n";
68 * Gets table informations
70 $show_comment = PMA_Table
::sGetStatusInfo($db, $table, 'TABLE_COMMENT');
73 * Gets table keys and retains them
75 $GLOBALS['dbi']->selectDb($db);
76 $indexes = $GLOBALS['dbi']->getTableIndexes($db, $table);
77 list($primary, $pk_array, $indexes_info, $indexes_data)
78 = PMA_Util
::processIndexData($indexes);
81 * Gets columns properties
83 $columns = $GLOBALS['dbi']->getColumns($db, $table);
85 // Check if we can use Relations
86 list($res_rel, $have_rel) = PMA_getRelationsAndStatus(
87 ! empty($cfgRelation['relation']), $db, $table
91 * Displays the comments of the table if MySQL >= 3.23
93 if (!empty($show_comment)) {
94 echo __('Table comments:') . ' ';
95 echo htmlspecialchars($show_comment) . '<br /><br />';
99 * Displays the table structure
102 echo '<table width="100%" class="print">';
103 echo '<tr><th width="50">' . __('Column') . '</th>';
104 echo '<th width="80">' . __('Type') . '</th>';
105 echo '<th width="40">' . __('Null') . '</th>';
106 echo '<th width="70">' . __('Default') . '</th>';
108 echo ' <th>' . __('Links to') . '</th>' . "\n";
110 echo ' <th>' . __('Comments') . '</th>' . "\n";
111 if ($cfgRelation['mimework']) {
112 echo ' <th>MIME</th>' . "\n";
116 foreach ($columns as $row) {
118 if ($row['Null'] == '') {
121 $extracted_columnspec
122 = PMA_Util
::extractColumnSpec($row['Type']);
124 // reformat mysql query output
125 // set or enum types: slashes single quotes inside options
126 if ('set' == $extracted_columnspec['type']
127 ||
'enum' == $extracted_columnspec['type']
132 $type_nowrap = ' class="nowrap"';
134 $type = htmlspecialchars($extracted_columnspec['print_type']);
135 $attribute = $extracted_columnspec['attribute'];
136 if (! isset($row['Default'])) {
137 if ($row['Null'] != 'NO') {
138 $row['Default'] = '<i>NULL</i>';
141 $row['Default'] = htmlspecialchars($row['Default']);
143 $column_name = $row['Field'];
146 echo $odd_row ?
'odd' : 'even'; $odd_row = ! $odd_row;
148 echo '<td class="nowrap">';
149 echo htmlspecialchars($column_name);
151 if (isset($pk_array[$row['Field']])) {
152 echo ' <em>(' . __('Primary') . ')</em>';
155 echo '<td' . $type_nowrap . ' lang="en" dir="ltr">' . $type . '</td>';
157 echo (($row['Null'] == 'NO') ?
__('No') : __('Yes'));
159 echo '<td class="nowrap">';
160 if (isset($row['Default'])) {
161 echo $row['Default'];
167 if ($foreigner = PMA_searchColumnInForeigners($res_rel, $column_name)) {
168 echo htmlspecialchars(
169 $foreigner['foreign_table']
171 . $foreigner['foreign_field']
177 if (isset($comments[$column_name])) {
178 echo htmlspecialchars($comments[$column_name]);
181 if ($cfgRelation['mimework']) {
182 $mime_map = PMA_getMIME($db, $table, true);
185 if (isset($mime_map[$column_name])) {
186 echo htmlspecialchars(
187 str_replace('_', '/', $mime_map[$column_name]['mimetype'])
196 // display indexes information
197 if (count(PMA_Index
::getFromTable($table, $db)) > 0) {
198 echo PMA_Index
::getView($table, $db, true);
204 * Displays the footer
206 echo PMA_Util
::getButton();