diff --git a/htdocs/sql/tbl_structure.php b/htdocs/sql/tbl_structure.php new file mode 100755 --- /dev/null +++ b/htdocs/sql/tbl_structure.php @@ -0,0 +1,851 @@ +'; + } else { + $iconic_spacer = ''; + } + + // images replaced 2004-05-08 by mkkeck + $titles['Change'] = $iconic_spacer + . '' . $strChange . ''; + $titles['Drop'] = $iconic_spacer + . '' . $strDrop . ''; + $titles['NoDrop'] = $iconic_spacer + . '' . $strDrop . ''; + $titles['Primary'] = $iconic_spacer + . '' . $strPrimary . ''; + $titles['Index'] = $iconic_spacer + . '' . $strIndex . ''; + $titles['Unique'] = $iconic_spacer + . '' . $strUnique . ''; + $titles['IdxFulltext'] = $iconic_spacer + . '' . $strIdxFulltext . ''; + $titles['NoPrimary'] = $iconic_spacer + . '' . $strPrimary . ''; + $titles['NoIndex'] = $iconic_spacer + . '' . $strIndex . ''; + $titles['NoUnique'] = $iconic_spacer + . '' . $strUnique . ''; + $titles['NoIdxFulltext'] = $iconic_spacer + . '' . $strIdxFulltext . ''; + $titles['BrowseDistinctValues'] = $iconic_spacer + . '' . $strBrowseDistinctValues . ''; + + if ($cfg['PropertiesIconic'] === 'both') { + $titles['Change'] .= $strChange . ''; + $titles['Drop'] .= $strDrop . ''; + $titles['NoDrop'] .= $strDrop . ''; + $titles['Primary'] .= $strPrimary . ''; + $titles['Index'] .= $strIndex . ''; + $titles['Unique'] .= $strUnique . ''; + $titles['IdxFulltext' ] .= $strIdxFulltext . ''; + $titles['NoPrimary'] .= $strPrimary . ''; + $titles['NoIndex'] .= $strIndex . ''; + $titles['NoUnique'] .= $strUnique . ''; + $titles['NoIdxFulltext'] .= $strIdxFulltext . ''; + $titles['BrowseDistinctValues'] .= $strBrowseDistinctValues . ''; + } +} else { + $titles['Change'] = $strChange; + $titles['Drop'] = $strDrop; + $titles['NoDrop'] = $strDrop; + $titles['Primary'] = $strPrimary; + $titles['Index'] = $strIndex; + $titles['Unique'] = $strUnique; + $titles['IdxFulltext'] = $strIdxFulltext; + $titles['NoPrimary'] = $strPrimary; + $titles['NoIndex'] = $strIndex; + $titles['NoUnique'] = $strUnique; + $titles['NoIdxFulltext'] = $strIdxFulltext; + $titles['BrowseDistinctValues'] = $strBrowseDistinctValues; +} + +/** + * Displays the table structure ('show table' works correct since 3.23.03) + */ +/* TABLE INFORMATION */ +// table header +$i = 0; +?> +
+ + + + + + + += 40100 ? ' ' . "\n" : ''; ?> + + + + + + + + + + + + += 40100) { + $comments_map = PMA_getComments($db, $table); + + if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) { + $mime_map = PMA_getMIME($db, $table, true); + } + } +} + +$rownum = 0; +$aryFields = array(); +$checked = (!empty($checkall) ? ' checked="checked"' : ''); +$save_row = array(); +$odd_row = true; +while ($row = PMA_DBI_fetch_assoc($fields_rs)) { + $save_row[] = $row; + $rownum++; + $aryFields[] = $row['Field']; + + $type = $row['Type']; + $type_and_length = PMA_extract_type_length($row['Type']); + + // reformat mysql query output - staybyte - 9. June 2001 + // loic1: set or enum types: slashes single quotes inside options + if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) { + $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1); + $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; + + // for the case ENUM('–','“') + $type = htmlspecialchars($type); + + $type_nowrap = ''; + + $binary = 0; + $unsigned = 0; + $zerofill = 0; + } else { + $type_nowrap = ' nowrap="nowrap"'; + // strip the "BINARY" attribute, except if we find "BINARY(" because + // this would be a BINARY or VARBINARY field type + if (!preg_match('@BINARY[\(]@i', $type)) { + $type = preg_replace('@BINARY@i', '', $type); + } + $type = preg_replace('@ZEROFILL@i', '', $type); + $type = preg_replace('@UNSIGNED@i', '', $type); + if (empty($type)) { + $type = ' '; + } + + if (!preg_match('@BINARY[\(]@i', $row['Type'])) { + $binary = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary'); + } else { + $binary = false; + } + + $unsigned = stristr($row['Type'], 'unsigned'); + $zerofill = stristr($row['Type'], 'zerofill'); + } + + // rabus: Divide charset from the rest of the type definition (MySQL >= 4.1) + unset($field_charset); + if (PMA_MYSQL_INT_VERSION >= 40100) { + if ((substr($type, 0, 4) == 'char' + || substr($type, 0, 7) == 'varchar' + || substr($type, 0, 4) == 'text' + || substr($type, 0, 8) == 'tinytext' + || substr($type, 0, 10) == 'mediumtext' + || substr($type, 0, 8) == 'longtext' + || substr($type, 0, 3) == 'set' + || substr($type, 0, 4) == 'enum' + ) && !$binary) { + if (strpos($type, ' character set ')) { + $type = substr($type, 0, strpos($type, ' character set ')); + } + if (!empty($row['Collation'])) { + $field_charset = $row['Collation']; + } else { + $field_charset = ''; + } + } else { + $field_charset = ''; + } + } + + // garvin: Display basic mimetype [MIME] + if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) { + $type_mime = '
MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']); + } else { + $type_mime = ''; + } + + $attribute = ' '; + if ($binary) { + $attribute = 'BINARY'; + } + if ($unsigned) { + $attribute = 'UNSIGNED'; + } + if ($zerofill) { + $attribute = 'UNSIGNED ZEROFILL'; + } + + // MySQL 4.1.2+ TIMESTAMP options + // (if on_update_current_timestamp is set, then it's TRUE) + if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) { + $attribute = 'ON UPDATE CURRENT_TIMESTAMP'; + } + + // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the + // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe + // the latter. + if (!empty($analyzed_sql[0]['create_table_fields'][$row['Field']]['type']) && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null']) { + $row['Null'] = ''; + } + + + if (!isset($row['Default'])) { + if ($row['Null'] == 'YES') { + $row['Default'] = 'NULL'; + } + } else { + $row['Default'] = htmlspecialchars($row['Default']); + } + + $field_encoded = urlencode($row['Field']); + $field_name = htmlspecialchars($row['Field']); + + // garvin: underline commented fields and display a hover-title (CSS only) + + $comment_style = ''; + if (isset($comments_map[$row['Field']])) { + $field_name = '' . $field_name . ''; + } + + if (isset($pk_array[$row['Field']])) { + $field_name = '' . $field_name . ''; + } + echo "\n"; + ?> + + + + > += 40100 ? ' ' . "\n" : '' ?> + + + + + + + + + + + + + + + + + + ' . "\n" + .'
' . $strCollation . '
+ /> + ' . (empty($field_charset) ? '' : '' . $field_charset . '') . ' + + + + + + + 1) { + echo "\n"; + ?> + + + + + + + + + + + + + + + + + + + + + + + +
' . "\n"; + +$checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table); +?> + +<?php echo $strWithChecked; ?> + + +/ + + + + + +' . "\n"; +} +if (! $tbl_is_view && ! $db_is_information_schema) { + if ($cfg['PropertiesIconic']) { + PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $strChange, 'b_edit.png'); + // Drop button if there is at least two fields + if ($fields_cnt > 1) { + PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', $strDrop, 'b_drop.png'); + } + if ('ARCHIVE' != $tbl_type) { + PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', $strPrimary, 'b_primary.png'); + PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', $strUnique, 'b_unique.png'); + PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', $strIndex, 'b_index.png'); + } + if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) { + PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', $strIdxFulltext, 'b_ftext.png'); + } + } else { + // Drop button if there is at least two fields + if ($fields_cnt > 1) { + echo '' . $strOr . '' . "\n" + . '' . "\n"; + } + if ('ARCHIVE' != $tbl_type) { + echo '' . $strOr . '' . "\n" + . '' . "\n"; + echo '' . $strOr . '' . "\n" + . '' . "\n"; + echo '' . $strOr . '' . "\n" + . '' . "\n"; + } + if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) { + echo '' . $strOr . '' . "\n" + . '' . "\n"; + } + } +} +?> +
+
+ + +'; +} +echo $strPrintView; +?> + + +'; + } + echo $strRelationView; + ?> + +'; + } + echo $strStructPropose; + ?>
+
+ '; + } + echo sprintf($strAddFields, ''); + ?> + + +