2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays the table structure ('show table' works correct since 3.23.03)
9 require_once 'libraries/common.inc.php';
10 require_once 'libraries/mysql_charsets.inc.php';
11 require_once 'libraries/structure.lib.php';
12 require_once 'libraries/index.lib.php';
13 require_once 'libraries/tbl_info.inc.php';
15 if (! defined('PHPMYADMIN')) {
19 /* TABLE INFORMATION */
23 $HideStructureActions = '';
24 if (PMA_Util
::showText('ActionLinksMode')
25 && $GLOBALS['cfg']['HideStructureActions'] === true
27 $HideStructureActions .= ' HideStructureActions';
30 $html_form = '<form method="post" action="tbl_structure.php" name="fieldsForm" '
31 . 'id="fieldsForm" class="ajax' . $HideStructureActions . '">';
33 $response->addHTML($html_form);
34 $response->addHTML(PMA_URL_getHiddenInputs($db, $table));
36 $tabletype = '<input type="hidden" name="table_type" value=';
37 if ($db_is_information_schema) {
38 $tabletype .= '"information_schema" />';
39 } else if ($tbl_is_view) {
40 $tabletype .= '"view" />';
42 $tabletype .= '"table" />';
44 $response->addHTML($tabletype);
46 $tablestructure = '<table id="tablestructure" class="data">';
47 $response->addHTML($tablestructure);
51 PMA_getHtmlForTableStructureHeader(
52 $db_is_information_schema,
57 $response->addHTML('<tbody>');
62 $comments_map = array();
65 if ($GLOBALS['cfg']['ShowPropertyComments']) {
66 include_once 'libraries/transformations.lib.php';
67 $comments_map = PMA_getComments($db, $table);
68 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
69 $mime_map = PMA_getMIME($db, $table, true);
74 $columns_list = array();
77 foreach ($fields as $row) {
80 $columns_list[] = $row['Field'];
83 $extracted_columnspec = PMA_Util
::extractColumnSpec($row['Type']);
85 if ('set' == $extracted_columnspec['type']
86 ||
'enum' == $extracted_columnspec['type']
90 $type_nowrap = ' class="nowrap"';
92 $type = $extracted_columnspec['print_type'];
98 if ($extracted_columnspec['can_contain_collation']
99 && ! empty($row['Collation'])
101 $field_charset = $row['Collation'];
104 // Display basic mimetype [MIME]
105 if ($cfgRelation['commwork']
106 && $cfgRelation['mimework']
107 && $cfg['BrowseMIME']
108 && isset($mime_map[$row['Field']]['mimetype'])
110 $type_mime = '<br />MIME: '
111 . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
116 $attribute = $extracted_columnspec['attribute'];
118 // prepare a common variable to reuse below; however,
119 // in case of a VIEW, $analyzed_sql[0]['create_table_fields'] is empty
120 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']])) {
121 $tempField = $analyzed_sql[0]['create_table_fields'][$row['Field']];
123 $tempField = array();
126 // MySQL 4.1.2+ TIMESTAMP options
127 // (if on_update_current_timestamp is set, then it's TRUE)
128 if (isset($tempField['on_update_current_timestamp'])) {
129 $attribute = 'on update CURRENT_TIMESTAMP';
132 // here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as having the
133 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
135 if (! empty($tempField['type'])
136 && $tempField['type'] == 'TIMESTAMP'
137 && $tempField['timestamp_not_null']
143 if (! isset($row['Default'])) {
144 if ($row['Null'] == 'YES') {
145 $row['Default'] = '<i>NULL</i>';
148 $row['Default'] = htmlspecialchars($row['Default']);
151 $field_encoded = urlencode($row['Field']);
152 $field_name = htmlspecialchars($row['Field']);
153 $displayed_field_name = $field_name;
155 // underline commented fields and display a hover-title (CSS only)
157 if (isset($comments_map[$row['Field']])) {
158 $displayed_field_name = '<span class="commented_column" title="'
159 . htmlspecialchars($comments_map[$row['Field']]) . '">'
160 . $field_name . '</span>';
163 if ($primary && $primary->hasColumn($field_name)) {
164 $displayed_field_name = '<u>' . $field_name . '</u>';
167 '<tr class="' . ($odd_row ?
'odd': 'even') . '">'
169 $odd_row = !$odd_row;
172 PMA_getHtmlTableStructureRow(
173 $row, $rownum, $displayed_field_name,
174 $type_nowrap, $extracted_columnspec, $type_mime,
175 $field_charset, $attribute, $tbl_is_view,
176 $db_is_information_schema, $url_query, $field_encoded, $titles, $table
180 if (! $tbl_is_view && ! $db_is_information_schema) {
182 PMA_getHtmlForActionsInTableStructure(
183 $type, $tbl_storage_engine, $primary,
184 $field_name, $url_query, $titles, $row, $rownum,
185 $hidden_titles, $columns_with_unique_index
188 } // end if (! $tbl_is_view && ! $db_is_information_schema)
190 $response->addHTML('</tr>');
192 unset($field_charset);
195 $response->addHTML('</tbody></table>');
198 PMA_getHtmlForCheckAllTableColumn(
199 $pmaThemeImage, $text_dir, $tbl_is_view,
200 $db_is_information_schema, $tbl_storage_engine
208 PMA_getHtmlDivForMoveColumnsDialog()
216 $response->addHTML(PMA_getHtmlForEditView($url_params));
219 PMA_getHtmlForOptionalActionLinks(
220 $url_query, $tbl_is_view, $db_is_information_schema,
221 $tbl_storage_engine, $cfgRelation
225 if (! $tbl_is_view && ! $db_is_information_schema) {
226 $response->addHTML('<br />');
227 $response->addHTML(PMA_getHtmlForAddColumn($columns_list));
229 '<div id="index_div" class="ajax" >'
238 && ! $db_is_information_schema
239 && 'ARCHIVE' != $tbl_storage_engine
241 //return the list of index
244 PMA_Index
::getView($GLOBALS['table'], $GLOBALS['db'])
246 $response->addHTML(PMA_getHtmlForDisplayIndexes());
250 * Displays Space usage and row statistics
252 // BEGIN - Calc Table Space
253 // Get valid statistics whatever is the table type
254 if ($cfg['ShowStats']) {
255 //get table stats in HTML format
256 $tablestats = PMA_getHtmlForDisplayTableStats(
257 $showtable, $table_info_num_rows, $tbl_is_view,
258 $db_is_information_schema, $tbl_storage_engine,
259 $url_query, $tbl_collation
261 //returning the response in JSON format to be used by Ajax
262 $response->addJSON('tableStat', $tablestats);
263 $response->addHTML($tablestats);
265 // END - Calc Table Space
268 '<div class="clearfloat"></div>'