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();
38 * Gets the relations settings
40 $cfgRelation = Relation
::getRelationsParam();
45 PhpMyAdmin\Util
::checkParameters(array('db'));
48 * Defines the url to return to in case of error in a sql statement
50 $err_url = 'db_sql.php' . Url
::getCommon(array('db' => $db));
52 if ($cfgRelation['commwork']) {
53 $comment = Relation
::getDbComment($db);
59 echo '<p>' , __('Database comment')
60 , '<br /><i>' , htmlspecialchars($comment) , '</i></p>';
65 * Selects the database and gets tables names
67 $GLOBALS['dbi']->selectDb($db);
68 $tables = $GLOBALS['dbi']->getTables($db);
71 foreach ($tables as $table) {
72 $comments = Relation
::getComments($db, $table);
76 echo '<h2>' , htmlspecialchars($table) , '</h2>' , "\n";
79 * Gets table information
81 $show_comment = $GLOBALS['dbi']->getTable($db, $table)
82 ->getStatusInfo('TABLE_COMMENT');
85 * Gets table keys and retains them
87 $GLOBALS['dbi']->selectDb($db);
88 $indexes = $GLOBALS['dbi']->getTableIndexes($db, $table);
89 list($primary, $pk_array, $indexes_info, $indexes_data)
90 = PhpMyAdmin\Util
::processIndexData($indexes);
93 * Gets columns properties
95 $columns = $GLOBALS['dbi']->getColumns($db, $table);
97 // Check if we can use Relations
98 list($res_rel, $have_rel) = Relation
::getRelationsAndStatus(
99 ! empty($cfgRelation['relation']), $db, $table
103 * Displays the comments of the table if MySQL >= 3.23
105 if (!empty($show_comment)) {
106 echo __('Table comments:') , ' ';
107 echo htmlspecialchars($show_comment) , '<br /><br />';
111 * Displays the table structure
114 echo '<table width="100%" class="print">';
115 echo '<tr><th width="50">' , __('Column') , '</th>';
116 echo '<th width="80">' , __('Type') , '</th>';
117 echo '<th width="40">' , __('Null') , '</th>';
118 echo '<th width="70">' , __('Default') , '</th>';
120 echo ' <th>' , __('Links to') , '</th>' , "\n";
122 echo ' <th>' , __('Comments') , '</th>' , "\n";
123 if ($cfgRelation['mimework']) {
124 echo ' <th>MIME</th>' , "\n";
127 foreach ($columns as $row) {
129 if ($row['Null'] == '') {
132 $extracted_columnspec
133 = PhpMyAdmin\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 '<td class="nowrap">';
151 echo htmlspecialchars($column_name);
153 if (isset($pk_array[$row['Field']])) {
154 echo ' <em>(' , __('Primary') , ')</em>';
158 , PhpMyAdmin\Util
::getClassForType(
159 $extracted_columnspec['type']
161 , ' lang="en" dir="ltr">' , $type , '</td>';
164 echo (($row['Null'] == 'NO') ?
__('No') : __('Yes'));
166 echo '<td class="nowrap">';
167 if (isset($row['Default'])) {
168 echo $row['Default'];
174 if ($foreigner = Relation
::searchColumnInForeigners($res_rel, $column_name)) {
175 echo htmlspecialchars(
176 $foreigner['foreign_table']
178 . $foreigner['foreign_field']
184 if (isset($comments[$column_name])) {
185 echo htmlspecialchars($comments[$column_name]);
188 if ($cfgRelation['mimework']) {
189 $mime_map = Transformations
::getMIME($db, $table, true);
192 if (isset($mime_map[$column_name])) {
193 echo htmlspecialchars(
194 str_replace('_', '/', $mime_map[$column_name]['mimetype'])
203 // display indexes information
204 if (count(PhpMyAdmin\Index
::getFromTable($table, $db)) > 0) {
205 echo PhpMyAdmin\Index
::getHtmlForIndexes($table, $db, true);
211 * Displays the footer
213 echo PhpMyAdmin\Util
::getButton();