Translated using Weblate (Ukrainian)
[phpmyadmin.git] / db_datadict.php
blob76926ae8b2c48036711f2bb54062bb3b3146d7ad
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Renders data dictionary
6 * @package PhpMyAdmin
7 */
8 declare(strict_types=1);
10 use PhpMyAdmin\Relation;
11 use PhpMyAdmin\Response;
12 use PhpMyAdmin\Transformations;
13 use PhpMyAdmin\Url;
15 /**
16 * Gets the variables sent or posted to this script, then displays headers
18 require_once 'libraries/common.inc.php';
20 if (! isset($selected_tbl)) {
21 include 'libraries/db_common.inc.php';
22 list(
23 $tables,
24 $num_tables,
25 $total_num_tables,
26 $sub_part,
27 $is_show_stats,
28 $db_is_system_schema,
29 $tooltip_truename,
30 $tooltip_aliasname,
31 $pos
32 ) = PhpMyAdmin\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
35 $response = Response::getInstance();
36 $header = $response->getHeader();
37 $header->enablePrintView();
39 $relation = new Relation($GLOBALS['dbi']);
40 $transformations = new Transformations();
42 /**
43 * Gets the relations settings
45 $cfgRelation = $relation->getRelationsParam();
47 /**
48 * Check parameters
50 PhpMyAdmin\Util::checkParameters(['db']);
52 /**
53 * Defines the url to return to in case of error in a sql statement
55 $err_url = 'db_sql.php' . Url::getCommon(['db' => $db]);
57 if ($cfgRelation['commwork']) {
58 $comment = $relation->getDbComment($db);
60 /**
61 * Displays DB comment
63 if ($comment) {
64 echo '<p>' , __('Database comment')
65 , '<br /><i>' , htmlspecialchars($comment) , '</i></p>';
66 } // end if
69 /**
70 * Selects the database and gets tables names
72 $GLOBALS['dbi']->selectDb($db);
73 $tables = $GLOBALS['dbi']->getTables($db);
75 $count = 0;
76 foreach ($tables as $table) {
77 $comments = $relation->getComments($db, $table);
79 echo '<div>' , "\n";
81 echo '<h2>' , htmlspecialchars($table) , '</h2>' , "\n";
83 /**
84 * Gets table information
86 $show_comment = $GLOBALS['dbi']->getTable($db, $table)
87 ->getStatusInfo('TABLE_COMMENT');
89 /**
90 * Gets table keys and retains them
92 $GLOBALS['dbi']->selectDb($db);
93 $indexes = $GLOBALS['dbi']->getTableIndexes($db, $table);
94 list($primary, $pk_array, $indexes_info, $indexes_data)
95 = PhpMyAdmin\Util::processIndexData($indexes);
97 /**
98 * Gets columns properties
100 $columns = $GLOBALS['dbi']->getColumns($db, $table);
102 // Check if we can use Relations
103 list($res_rel, $have_rel) = $relation->getRelationsAndStatus(
104 ! empty($cfgRelation['relation']),
105 $db,
106 $table
110 * Displays the comments of the table if MySQL >= 3.23
112 if (!empty($show_comment)) {
113 echo __('Table comments:') , ' ';
114 echo htmlspecialchars($show_comment) , '<br /><br />';
118 * Displays the table structure
121 echo '<table width="100%" class="print">';
122 echo '<tr><th width="50">' , __('Column') , '</th>';
123 echo '<th width="80">' , __('Type') , '</th>';
124 echo '<th width="40">' , __('Null') , '</th>';
125 echo '<th width="70">' , __('Default') , '</th>';
126 if ($have_rel) {
127 echo ' <th>' , __('Links to') , '</th>' , "\n";
129 echo ' <th>' , __('Comments') , '</th>' , "\n";
130 if ($cfgRelation['mimework']) {
131 echo ' <th>MIME</th>' , "\n";
133 echo '</tr>';
134 foreach ($columns as $row) {
135 if ($row['Null'] == '') {
136 $row['Null'] = 'NO';
138 $extracted_columnspec
139 = PhpMyAdmin\Util::extractColumnSpec($row['Type']);
141 // reformat mysql query output
142 // set or enum types: slashes single quotes inside options
144 $type = htmlspecialchars($extracted_columnspec['print_type']);
145 $attribute = $extracted_columnspec['attribute'];
146 if (! isset($row['Default'])) {
147 if ($row['Null'] != 'NO') {
148 $row['Default'] = '<i>NULL</i>';
150 } else {
151 $row['Default'] = htmlspecialchars($row['Default']);
153 $column_name = $row['Field'];
155 echo '<tr>';
156 echo '<td class="nowrap">';
157 echo htmlspecialchars($column_name);
159 if (isset($pk_array[$row['Field']])) {
160 echo ' <em>(' , __('Primary') , ')</em>';
162 echo '</td>';
163 echo '<td'
164 , PhpMyAdmin\Util::getClassForType(
165 $extracted_columnspec['type']
167 , ' lang="en" dir="ltr">' , $type , '</td>';
169 echo '<td>';
170 echo (($row['Null'] == 'NO') ? __('No') : __('Yes'));
171 echo '</td>';
172 echo '<td class="nowrap">';
173 if (isset($row['Default'])) {
174 echo $row['Default'];
176 echo '</td>';
178 if ($have_rel) {
179 echo ' <td>';
180 if ($foreigner = $relation->searchColumnInForeigners($res_rel, $column_name)) {
181 echo htmlspecialchars(
182 $foreigner['foreign_table']
183 . ' -> '
184 . $foreigner['foreign_field']
187 echo '</td>' , "\n";
189 echo ' <td>';
190 if (isset($comments[$column_name])) {
191 echo htmlspecialchars($comments[$column_name]);
193 echo '</td>' , "\n";
194 if ($cfgRelation['mimework']) {
195 $mime_map = $transformations->getMime($db, $table, true);
197 echo ' <td>';
198 if (isset($mime_map[$column_name])) {
199 echo htmlspecialchars(
200 str_replace('_', '/', $mime_map[$column_name]['mimetype'])
203 echo '</td>' , "\n";
205 echo '</tr>';
206 } // end foreach
207 $count++;
208 echo '</table>';
209 // display indexes information
210 if (count(PhpMyAdmin\Index::getFromTable($table, $db)) > 0) {
211 echo PhpMyAdmin\Index::getHtmlForIndexes($table, $db, true);
213 echo '</div>';
214 } //ends main while
217 * Displays the footer
219 echo PhpMyAdmin\Util::getButton();