2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Renders data dictionary
11 * Gets the variables sent or posted to this script, then displays headers
13 require_once 'libraries/common.inc.php';
15 if (! isset($selected_tbl)) {
16 include 'libraries/db_common.inc.php';
27 ) = PMA\libraries\Util
::getDbInfo($db, isset($sub_part) ?
$sub_part : '');
30 $response = PMA\libraries\Response
::getInstance();
31 $header = $response->getHeader();
32 $header->enablePrintView();
35 * Gets the relations settings
37 $cfgRelation = PMA_getRelationsParam();
39 require_once 'libraries/transformations.lib.php';
44 PMA\libraries\Util
::checkParameters(array('db'));
47 * Defines the url to return to in case of error in a sql statement
49 $err_url = 'db_sql.php' . URL
::getCommon(array('db' => $db));
51 if ($cfgRelation['commwork']) {
52 $comment = PMA_getDbComment($db);
58 echo '<p>' , __('Database comment')
59 , '<br /><i>' , htmlspecialchars($comment) , '</i></p>';
64 * Selects the database and gets tables names
66 $GLOBALS['dbi']->selectDb($db);
67 $tables = $GLOBALS['dbi']->getTables($db);
70 foreach ($tables as $table) {
71 $comments = PMA_getComments($db, $table);
75 echo '<h2>' , htmlspecialchars($table) , '</h2>' , "\n";
78 * Gets table information
80 $show_comment = $GLOBALS['dbi']->getTable($db, $table)
81 ->getStatusInfo('TABLE_COMMENT');
84 * Gets table keys and retains them
86 $GLOBALS['dbi']->selectDb($db);
87 $indexes = $GLOBALS['dbi']->getTableIndexes($db, $table);
88 list($primary, $pk_array, $indexes_info, $indexes_data)
89 = PMA\libraries\Util
::processIndexData($indexes);
92 * Gets columns properties
94 $columns = $GLOBALS['dbi']->getColumns($db, $table);
96 // Check if we can use Relations
97 list($res_rel, $have_rel) = PMA_getRelationsAndStatus(
98 ! empty($cfgRelation['relation']), $db, $table
102 * Displays the comments of the table if MySQL >= 3.23
104 if (!empty($show_comment)) {
105 echo __('Table comments:') , ' ';
106 echo htmlspecialchars($show_comment) , '<br /><br />';
110 * Displays the table structure
113 echo '<table width="100%" class="print">';
114 echo '<tr><th width="50">' , __('Column') , '</th>';
115 echo '<th width="80">' , __('Type') , '</th>';
116 echo '<th width="40">' , __('Null') , '</th>';
117 echo '<th width="70">' , __('Default') , '</th>';
119 echo ' <th>' , __('Links to') , '</th>' , "\n";
121 echo ' <th>' , __('Comments') , '</th>' , "\n";
122 if ($cfgRelation['mimework']) {
123 echo ' <th>MIME</th>' , "\n";
127 foreach ($columns as $row) {
129 if ($row['Null'] == '') {
132 $extracted_columnspec
133 = PMA\libraries\Util
::extractColumnSpec($row['Type']);
135 // reformat mysql query output
136 // set or enum types: slashes single quotes inside options
138 $type = htmlspecialchars($extracted_columnspec['print_type']);
139 $attribute = $extracted_columnspec['attribute'];
140 if (! isset($row['Default'])) {
141 if ($row['Null'] != 'NO') {
142 $row['Default'] = '<i>NULL</i>';
145 $row['Default'] = htmlspecialchars($row['Default']);
147 $column_name = $row['Field'];
150 echo $odd_row ?
'odd' : 'even'; $odd_row = ! $odd_row;
152 echo '<td class="nowrap">';
153 echo htmlspecialchars($column_name);
155 if (isset($pk_array[$row['Field']])) {
156 echo ' <em>(' , __('Primary') , ')</em>';
160 , PMA\libraries\Util
::getClassForType(
161 $extracted_columnspec['type']
163 , ' lang="en" dir="ltr">' , $type , '</td>';
166 echo (($row['Null'] == 'NO') ?
__('No') : __('Yes'));
168 echo '<td class="nowrap">';
169 if (isset($row['Default'])) {
170 echo $row['Default'];
176 if ($foreigner = PMA_searchColumnInForeigners($res_rel, $column_name)) {
177 echo htmlspecialchars(
178 $foreigner['foreign_table']
180 . $foreigner['foreign_field']
186 if (isset($comments[$column_name])) {
187 echo htmlspecialchars($comments[$column_name]);
190 if ($cfgRelation['mimework']) {
191 $mime_map = PMA_getMIME($db, $table, true);
194 if (isset($mime_map[$column_name])) {
195 echo htmlspecialchars(
196 str_replace('_', '/', $mime_map[$column_name]['mimetype'])
205 // display indexes information
206 if (count(PMA\libraries\Index
::getFromTable($table, $db)) > 0) {
207 echo PMA\libraries\Index
::getHtmlForIndexes($table, $db, true);
213 * Displays the footer
215 echo PMA\libraries\Util
::getButton();