2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Renders data dictionary
8 use PhpMyAdmin\Relation
;
9 use PhpMyAdmin\Response
;
10 use PhpMyAdmin\Transformations
;
14 * Gets the variables sent or posted to this script, then displays headers
16 require_once 'libraries/common.inc.php';
18 if (! isset($selected_tbl)) {
19 include 'libraries/db_common.inc.php';
30 ) = PhpMyAdmin\Util
::getDbInfo($db, isset($sub_part) ?
$sub_part : '');
33 $response = Response
::getInstance();
34 $header = $response->getHeader();
35 $header->enablePrintView();
37 $relation = new Relation();
40 * Gets the relations settings
42 $cfgRelation = $relation->getRelationsParam();
47 PhpMyAdmin\Util
::checkParameters(array('db'));
50 * Defines the url to return to in case of error in a sql statement
52 $err_url = 'db_sql.php' . Url
::getCommon(array('db' => $db));
54 if ($cfgRelation['commwork']) {
55 $comment = $relation->getDbComment($db);
61 echo '<p>' , __('Database comment')
62 , '<br /><i>' , htmlspecialchars($comment) , '</i></p>';
67 * Selects the database and gets tables names
69 $GLOBALS['dbi']->selectDb($db);
70 $tables = $GLOBALS['dbi']->getTables($db);
73 foreach ($tables as $table) {
74 $comments = $relation->getComments($db, $table);
78 echo '<h2>' , htmlspecialchars($table) , '</h2>' , "\n";
81 * Gets table information
83 $show_comment = $GLOBALS['dbi']->getTable($db, $table)
84 ->getStatusInfo('TABLE_COMMENT');
87 * Gets table keys and retains them
89 $GLOBALS['dbi']->selectDb($db);
90 $indexes = $GLOBALS['dbi']->getTableIndexes($db, $table);
91 list($primary, $pk_array, $indexes_info, $indexes_data)
92 = PhpMyAdmin\Util
::processIndexData($indexes);
95 * Gets columns properties
97 $columns = $GLOBALS['dbi']->getColumns($db, $table);
99 // Check if we can use Relations
100 list($res_rel, $have_rel) = $relation->getRelationsAndStatus(
101 ! empty($cfgRelation['relation']), $db, $table
105 * Displays the comments of the table if MySQL >= 3.23
107 if (!empty($show_comment)) {
108 echo __('Table comments:') , ' ';
109 echo htmlspecialchars($show_comment) , '<br /><br />';
113 * Displays the table structure
116 echo '<table width="100%" class="print">';
117 echo '<tr><th width="50">' , __('Column') , '</th>';
118 echo '<th width="80">' , __('Type') , '</th>';
119 echo '<th width="40">' , __('Null') , '</th>';
120 echo '<th width="70">' , __('Default') , '</th>';
122 echo ' <th>' , __('Links to') , '</th>' , "\n";
124 echo ' <th>' , __('Comments') , '</th>' , "\n";
125 if ($cfgRelation['mimework']) {
126 echo ' <th>MIME</th>' , "\n";
129 foreach ($columns as $row) {
131 if ($row['Null'] == '') {
134 $extracted_columnspec
135 = PhpMyAdmin\Util
::extractColumnSpec($row['Type']);
137 // reformat mysql query output
138 // set or enum types: slashes single quotes inside options
140 $type = htmlspecialchars($extracted_columnspec['print_type']);
141 $attribute = $extracted_columnspec['attribute'];
142 if (! isset($row['Default'])) {
143 if ($row['Null'] != 'NO') {
144 $row['Default'] = '<i>NULL</i>';
147 $row['Default'] = htmlspecialchars($row['Default']);
149 $column_name = $row['Field'];
152 echo '<td class="nowrap">';
153 echo htmlspecialchars($column_name);
155 if (isset($pk_array[$row['Field']])) {
156 echo ' <em>(' , __('Primary') , ')</em>';
160 , PhpMyAdmin\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 = $relation->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 = Transformations
::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(PhpMyAdmin\Index
::getFromTable($table, $db)) > 0) {
207 echo PhpMyAdmin\Index
::getHtmlForIndexes($table, $db, true);
213 * Displays the footer
215 echo PhpMyAdmin\Util
::getButton();