Translated using Weblate (Armenian)
[phpmyadmin.git] / db_datadict.php
blobe53c992dfe52c0752726f880a1518b5a3eeaf7a7
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Renders data dictionary
6 * @package PhpMyAdmin
7 */
9 /**
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();
23 /**
24 * Gets the relations settings
26 $cfgRelation = PMA_getRelationsParam();
28 require_once 'libraries/transformations.lib.php';
29 require_once 'libraries/Index.class.php';
31 /**
32 * Check parameters
34 PMA_Util::checkParameters(array('db'));
36 /**
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);
44 /**
45 * Displays DB comment
47 if ($comment) {
48 echo '<p>' . __('Database comment')
49 . '<br /><i>' . htmlspecialchars($comment) . '</i></p>';
50 } // end if
53 /**
54 * Selects the database and gets tables names
56 $GLOBALS['dbi']->selectDb($db);
57 $tables = $GLOBALS['dbi']->getTables($db);
59 $count = 0;
60 foreach ($tables as $table) {
61 $comments = PMA_getComments($db, $table);
63 echo '<div>' . "\n";
65 echo '<h2>' . htmlspecialchars($table) . '</h2>' . "\n";
67 /**
68 * Gets table information
70 $show_comment = $GLOBALS['dbi']->getTable($db, $table)->sGetStatusInfo('TABLE_COMMENT');
72 /**
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);
80 /**
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
90 /**
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 />';
98 /**
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>';
107 if ($have_rel) {
108 echo ' <th>' . __('Links to') . '</th>' . "\n";
110 echo ' <th>' . __('Comments') . '</th>' . "\n";
111 if ($cfgRelation['mimework']) {
112 echo ' <th>MIME</th>' . "\n";
114 echo '</tr>';
115 $odd_row = true;
116 foreach ($columns as $row) {
118 if ($row['Null'] == '') {
119 $row['Null'] = 'NO';
121 $extracted_columnspec
122 = PMA_Util::extractColumnSpec($row['Type']);
124 // reformat mysql query output
125 // set or enum types: slashes single quotes inside options
127 $type = htmlspecialchars($extracted_columnspec['print_type']);
128 $attribute = $extracted_columnspec['attribute'];
129 if (! isset($row['Default'])) {
130 if ($row['Null'] != 'NO') {
131 $row['Default'] = '<i>NULL</i>';
133 } else {
134 $row['Default'] = htmlspecialchars($row['Default']);
136 $column_name = $row['Field'];
138 echo '<tr class="';
139 echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row;
140 echo '">';
141 echo '<td class="nowrap">';
142 echo htmlspecialchars($column_name);
144 if (isset($pk_array[$row['Field']])) {
145 echo ' <em>(' . __('Primary') . ')</em>';
147 echo '</td>';
148 echo '<td'
149 . PMA_Util::getClassForType(
150 $extracted_columnspec['type']
152 . ' lang="en" dir="ltr">' . $type . '</td>';
154 echo '<td>';
155 echo (($row['Null'] == 'NO') ? __('No') : __('Yes'));
156 echo '</td>';
157 echo '<td class="nowrap">';
158 if (isset($row['Default'])) {
159 echo $row['Default'];
161 echo '</td>';
163 if ($have_rel) {
164 echo ' <td>';
165 if ($foreigner = PMA_searchColumnInForeigners($res_rel, $column_name)) {
166 echo htmlspecialchars(
167 $foreigner['foreign_table']
168 . ' -> '
169 . $foreigner['foreign_field']
172 echo '</td>' . "\n";
174 echo ' <td>';
175 if (isset($comments[$column_name])) {
176 echo htmlspecialchars($comments[$column_name]);
178 echo '</td>' . "\n";
179 if ($cfgRelation['mimework']) {
180 $mime_map = PMA_getMIME($db, $table, true);
182 echo ' <td>';
183 if (isset($mime_map[$column_name])) {
184 echo htmlspecialchars(
185 str_replace('_', '/', $mime_map[$column_name]['mimetype'])
188 echo '</td>' . "\n";
190 echo '</tr>';
191 } // end foreach
192 $count++;
193 echo '</table>';
194 // display indexes information
195 if (count(PMA_Index::getFromTable($table, $db)) > 0) {
196 echo PMA_Index::getHtmlForIndexes($table, $db, true);
198 echo '</div>';
199 } //ends main while
202 * Displays the footer
204 echo PMA_Util::getButton();