Translated using Weblate (Hungarian)
[phpmyadmin.git] / tbl_structure.php
blobb40c57dabc958ea7b5038e762219d739ff7d0fad
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Displays table structure infos like columns, indexes, size, rows
5 * and allows manipulation of indexes and columns
7 * @package PhpMyAdmin
8 */
10 /**
13 require_once 'libraries/common.inc.php';
14 require_once 'libraries/mysql_charsets.inc.php';
16 /**
17 * Function implementations for this script
19 require_once 'libraries/structure.lib.php';
20 require_once 'libraries/index.lib.php';
21 require_once 'libraries/sql.lib.php';
22 require_once 'libraries/bookmark.lib.php';
24 $response = PMA_Response::getInstance();
25 $header = $response->getHeader();
26 $scripts = $header->getScripts();
27 $scripts->addFile('tbl_structure.js');
28 $scripts->addFile('indexes.js');
30 /**
31 * Handle column moving
33 if (isset($_REQUEST['move_columns'])
34 && is_array($_REQUEST['move_columns'])
35 && $response->isAjax()
36 ) {
37 PMA_moveColumns($db, $table);
38 exit;
41 /**
42 * A click on Change has been made for one column
44 if (isset($_REQUEST['change_column'])) {
45 PMA_displayHtmlForColumnChange($db, $table, null, 'tbl_structure.php');
46 exit;
48 /**
49 * Modifications have been submitted -> updates the table
51 if (isset($_REQUEST['do_save_data'])) {
52 $regenerate = PMA_updateColumns($db, $table);
53 if ($regenerate) {
54 // This happens when updating failed
55 // @todo: do something appropriate
56 } else {
57 // continue to show the table's structure
58 unset($_REQUEST['selected']);
62 /**
63 * handle multiple field commands if required
65 * submit_mult_*_x comes from IE if <input type="img" ...> is used
67 $submit_mult = PMA_getMultipleFieldCommandType();
69 if (! empty($submit_mult)) {
70 if (isset($_REQUEST['selected_fld'])) {
71 if ($submit_mult == 'browse') {
72 // browsing the table displaying only selected columns
73 PMA_displayTableBrowseForSelectedColumns(
74 $db, $table, $goto, $pmaThemeImage
76 } else {
77 // handle multiple field commands
78 // handle confirmation of deleting multiple columns
79 $action = 'tbl_structure.php';
80 include 'libraries/mult_submits.inc.php';
81 /**
82 * if $submit_mult == 'change', execution will have stopped
83 * at this point
86 if (empty($message)) {
87 $message = PMA_Message::success();
90 } else {
91 $response = PMA_Response::getInstance();
92 $response->isSuccess(false);
93 $response->addJSON('message', __('No column selected.'));
97 /**
98 * Gets the relation settings
100 $cfgRelation = PMA_getRelationsParam();
103 * Runs common work
105 require_once 'libraries/tbl_common.inc.php';
106 $url_query .= '&amp;goto=tbl_structure.php&amp;back=tbl_structure.php';
107 $url_params['goto'] = 'tbl_structure.php';
108 $url_params['back'] = 'tbl_structure.php';
110 // Check column names for MySQL reserved words
111 $reserved_word_column_messages = PMA_getReservedWordColumnNameMessages($db, $table);
112 $response->addHTML($reserved_word_column_messages);
115 * Prepares the table structure display
120 * Gets tables informations
122 require_once 'libraries/tbl_info.inc.php';
124 require_once 'libraries/Index.class.php';
126 // 2. Gets table keys and retains them
127 // @todo should be: $server->db($db)->table($table)->primary()
128 $primary = PMA_Index::getPrimary($table, $db);
130 $columns_with_unique_index = PMA_getColumnsWithUniqueIndex($db, $table);
132 // 3. Get fields
133 $fields = (array) $GLOBALS['dbi']->getColumns($db, $table, null, true);
135 // Get more complete field information
136 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
137 // but later, if the analyser returns more information, it
138 // could be executed for any MySQL version and replace
139 // the info given by SHOW FULL COLUMNS FROM.
141 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
142 // SHOW FULL COLUMNS or INFORMATION_SCHEMA incorrectly says NULL
143 // and SHOW CREATE TABLE says NOT NULL (tested
144 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
146 $show_create_table = $GLOBALS['dbi']->fetchValue(
147 'SHOW CREATE TABLE ' . PMA_Util::backquote($db) . '.'
148 . PMA_Util::backquote($table),
149 0, 1
151 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
154 * prepare table infos
156 // action titles (image or string)
157 $titles = PMA_getActionTitlesArray();
159 // hidden action titles (image and string)
160 $hidden_titles = PMA_getHiddenTitlesArray();
162 //display table structure
163 require_once 'libraries/display_structure.inc.php';