Translated using Weblate (Kazakh)
[phpmyadmin.git] / db_datadict.php
blob7a5d7f4fa3fb3125e75df8cc621aaddc7108db84
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Renders data dictionary
6 * @package PhpMyAdmin
7 */
8 use PhpMyAdmin\Relation;
9 use PhpMyAdmin\Response;
10 use PhpMyAdmin\Transformations;
11 use PhpMyAdmin\Url;
13 /**
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';
20 list(
21 $tables,
22 $num_tables,
23 $total_num_tables,
24 $sub_part,
25 $is_show_stats,
26 $db_is_system_schema,
27 $tooltip_truename,
28 $tooltip_aliasname,
29 $pos
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();
39 /**
40 * Gets the relations settings
42 $cfgRelation = $relation->getRelationsParam();
44 /**
45 * Check parameters
47 PhpMyAdmin\Util::checkParameters(array('db'));
49 /**
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);
57 /**
58 * Displays DB comment
60 if ($comment) {
61 echo '<p>' , __('Database comment')
62 , '<br /><i>' , htmlspecialchars($comment) , '</i></p>';
63 } // end if
66 /**
67 * Selects the database and gets tables names
69 $GLOBALS['dbi']->selectDb($db);
70 $tables = $GLOBALS['dbi']->getTables($db);
72 $count = 0;
73 foreach ($tables as $table) {
74 $comments = $relation->getComments($db, $table);
76 echo '<div>' , "\n";
78 echo '<h2>' , htmlspecialchars($table) , '</h2>' , "\n";
80 /**
81 * Gets table information
83 $show_comment = $GLOBALS['dbi']->getTable($db, $table)
84 ->getStatusInfo('TABLE_COMMENT');
86 /**
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);
94 /**
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>';
121 if ($have_rel) {
122 echo ' <th>' , __('Links to') , '</th>' , "\n";
124 echo ' <th>' , __('Comments') , '</th>' , "\n";
125 if ($cfgRelation['mimework']) {
126 echo ' <th>MIME</th>' , "\n";
128 echo '</tr>';
129 foreach ($columns as $row) {
131 if ($row['Null'] == '') {
132 $row['Null'] = 'NO';
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>';
146 } else {
147 $row['Default'] = htmlspecialchars($row['Default']);
149 $column_name = $row['Field'];
151 echo '<tr>';
152 echo '<td class="nowrap">';
153 echo htmlspecialchars($column_name);
155 if (isset($pk_array[$row['Field']])) {
156 echo ' <em>(' , __('Primary') , ')</em>';
158 echo '</td>';
159 echo '<td'
160 , PhpMyAdmin\Util::getClassForType(
161 $extracted_columnspec['type']
163 , ' lang="en" dir="ltr">' , $type , '</td>';
165 echo '<td>';
166 echo (($row['Null'] == 'NO') ? __('No') : __('Yes'));
167 echo '</td>';
168 echo '<td class="nowrap">';
169 if (isset($row['Default'])) {
170 echo $row['Default'];
172 echo '</td>';
174 if ($have_rel) {
175 echo ' <td>';
176 if ($foreigner = $relation->searchColumnInForeigners($res_rel, $column_name)) {
177 echo htmlspecialchars(
178 $foreigner['foreign_table']
179 . ' -> '
180 . $foreigner['foreign_field']
183 echo '</td>' , "\n";
185 echo ' <td>';
186 if (isset($comments[$column_name])) {
187 echo htmlspecialchars($comments[$column_name]);
189 echo '</td>' , "\n";
190 if ($cfgRelation['mimework']) {
191 $mime_map = Transformations::getMIME($db, $table, true);
193 echo ' <td>';
194 if (isset($mime_map[$column_name])) {
195 echo htmlspecialchars(
196 str_replace('_', '/', $mime_map[$column_name]['mimetype'])
199 echo '</td>' , "\n";
201 echo '</tr>';
202 } // end foreach
203 $count++;
204 echo '</table>';
205 // display indexes information
206 if (count(PhpMyAdmin\Index::getFromTable($table, $db)) > 0) {
207 echo PhpMyAdmin\Index::getHtmlForIndexes($table, $db, true);
209 echo '</div>';
210 } //ends main while
213 * Displays the footer
215 echo PhpMyAdmin\Util::getButton();