| [ Index ] |
|
Code source de phpMyAdmin 2.10.3 |
1 <?php 2 /* $Id: tbl_structure.php 10379 2007-05-11 17:11:39Z lem9 $ */ 3 // vim: expandtab sw=4 ts=4 sts=4: 4 5 require_once './libraries/common.lib.php'; 6 require_once './libraries/mysql_charsets.lib.php'; 7 require_once './libraries/relation.lib.php'; 8 9 /** 10 * Gets the relation settings 11 */ 12 $cfgRelation = PMA_getRelationsParam(); 13 14 15 /** 16 * Drop multiple fields if required 17 */ 18 19 // workaround for IE problem: 20 if (isset($submit_mult_change_x)) { 21 $submit_mult = $strChange; 22 } elseif (isset($submit_mult_drop_x)) { 23 $submit_mult = $strDrop; 24 } elseif (isset($submit_mult_primary_x)) { 25 $submit_mult = $strPrimary; 26 } elseif (isset($submit_mult_index_x)) { 27 $submit_mult = $strIndex; 28 } elseif (isset($submit_mult_unique_x)) { 29 $submit_mult = $strUnique; 30 } elseif (isset($submit_mult_fulltext_x)) { 31 $submit_mult = $strIdxFulltext; 32 } 33 34 if ((!empty($submit_mult) && isset($selected_fld)) 35 || isset($mult_btn)) { 36 $action = 'tbl_structure.php'; 37 $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table); 38 require_once ('./libraries/header.inc.php'); 39 require_once './libraries/tbl_links.inc.php'; 40 require './libraries/mult_submits.inc.php'; 41 } 42 43 /** 44 * Runs common work 45 */ 46 require_once './libraries/tbl_common.php'; 47 $url_query .= '&goto=tbl_structure.php&back=tbl_structure.php'; 48 49 /** 50 * Prepares the table structure display 51 */ 52 53 /** 54 * Gets tables informations 55 */ 56 require_once './libraries/tbl_info.inc.php'; 57 58 /** 59 * Show result of multi submit operation 60 */ 61 if ((!empty($submit_mult) && isset($selected_fld)) 62 || isset($mult_btn)) { 63 $message = $strSuccess; 64 } 65 66 /** 67 * Displays top menu links 68 */ 69 require_once './libraries/tbl_links.inc.php'; 70 71 // 2. Gets table keys and retains them 72 $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($table) . ';'); 73 $primary = ''; 74 $ret_keys = array(); 75 $pk_array = array(); // will be use to emphasis prim. keys in the table view 76 while ($row = PMA_DBI_fetch_assoc($result)) { 77 $ret_keys[] = $row; 78 // Backups the list of primary keys 79 if ($row['Key_name'] == 'PRIMARY') { 80 $primary .= $row['Column_name'] . ', '; 81 $pk_array[$row['Column_name']] = 1; 82 } 83 } // end while 84 PMA_DBI_free_result($result); 85 86 // 3. Get fields 87 $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE); 88 $fields_cnt = PMA_DBI_num_rows($fields_rs); 89 90 // Get more complete field information 91 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options 92 // but later, if the analyser returns more information, it 93 // could be executed for any MySQL version and replace 94 // the info given by SHOW FULL FIELDS FROM. 95 // 96 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since 97 // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL 98 // and SHOW CREATE TABLE says NOT NULL (tested 99 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910). 100 101 $show_create_table = PMA_DBI_fetch_value( 102 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 103 0, 1); 104 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table)); 105 106 /** 107 * prepare table infos 108 */ 109 // action titles (image or string) 110 $titles = array(); 111 if ($cfg['PropertiesIconic'] == true) { 112 if ($cfg['PropertiesIconic'] === 'both') { 113 $iconic_spacer = '<div class="nowrap">'; 114 } else { 115 $iconic_spacer = ''; 116 } 117 118 // images replaced 2004-05-08 by mkkeck 119 $titles['Change'] = $iconic_spacer 120 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage 121 . 'b_edit.png" alt="' . $strChange . '" title="' . $strChange . '" />'; 122 $titles['Drop'] = $iconic_spacer 123 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage 124 . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />'; 125 $titles['NoDrop'] = $iconic_spacer 126 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage 127 . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />'; 128 $titles['Primary'] = $iconic_spacer 129 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage 130 . 'b_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />'; 131 $titles['Index'] = $iconic_spacer 132 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage 133 . 'b_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />'; 134 $titles['Unique'] = $iconic_spacer 135 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage 136 . 'b_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />'; 137 $titles['IdxFulltext'] = $iconic_spacer 138 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage 139 . 'b_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />'; 140 $titles['NoPrimary'] = $iconic_spacer 141 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage 142 . 'bd_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />'; 143 $titles['NoIndex'] = $iconic_spacer 144 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage 145 . 'bd_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />'; 146 $titles['NoUnique'] = $iconic_spacer 147 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage 148 . 'bd_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />'; 149 $titles['NoIdxFulltext'] = $iconic_spacer 150 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage 151 . 'bd_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />'; 152 $titles['BrowseDistinctValues'] = $iconic_spacer 153 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage 154 . 'b_browse.png" alt="' . $strBrowseDistinctValues . '" title="' . $strBrowseDistinctValues . '" />'; 155 156 if ($cfg['PropertiesIconic'] === 'both') { 157 $titles['Change'] .= $strChange . '</div>'; 158 $titles['Drop'] .= $strDrop . '</div>'; 159 $titles['NoDrop'] .= $strDrop . '</div>'; 160 $titles['Primary'] .= $strPrimary . '</div>'; 161 $titles['Index'] .= $strIndex . '</div>'; 162 $titles['Unique'] .= $strUnique . '</div>'; 163 $titles['IdxFulltext' ] .= $strIdxFulltext . '</div>'; 164 $titles['NoPrimary'] .= $strPrimary . '</div>'; 165 $titles['NoIndex'] .= $strIndex . '</div>'; 166 $titles['NoUnique'] .= $strUnique . '</div>'; 167 $titles['NoIdxFulltext'] .= $strIdxFulltext . '</div>'; 168 $titles['BrowseDistinctValues'] .= $strBrowseDistinctValues . '</div>'; 169 } 170 } else { 171 $titles['Change'] = $strChange; 172 $titles['Drop'] = $strDrop; 173 $titles['NoDrop'] = $strDrop; 174 $titles['Primary'] = $strPrimary; 175 $titles['Index'] = $strIndex; 176 $titles['Unique'] = $strUnique; 177 $titles['IdxFulltext'] = $strIdxFulltext; 178 $titles['NoPrimary'] = $strPrimary; 179 $titles['NoIndex'] = $strIndex; 180 $titles['NoUnique'] = $strUnique; 181 $titles['NoIdxFulltext'] = $strIdxFulltext; 182 $titles['BrowseDistinctValues'] = $strBrowseDistinctValues; 183 } 184 185 /** 186 * Displays the table structure ('show table' works correct since 3.23.03) 187 */ 188 /* TABLE INFORMATION */ 189 // table header 190 $i = 0; 191 ?> 192 <form method="post" action="tbl_structure.php" name="fieldsForm" id="fieldsForm"> 193 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?> 194 <table id="tablestructure" class="data"> 195 <thead> 196 <tr> 197 <th id="th<?php echo ++$i; ?>"></th> 198 <th id="th<?php echo ++$i; ?>"><?php echo $strField; ?></th> 199 <th id="th<?php echo ++$i; ?>"><?php echo $strType; ?></th> 200 <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? ' <th id="th' . ++$i . '">' . $strCollation . '</th>' . "\n" : ''; ?> 201 <th id="th<?php echo ++$i; ?>"><?php echo $strAttr; ?></th> 202 <th id="th<?php echo ++$i; ?>"><?php echo $strNull; ?></th> 203 <th id="th<?php echo ++$i; ?>"><?php echo $strDefault; ?></th> 204 <th id="th<?php echo ++$i; ?>"><?php echo $strExtra; ?></th> 205 <?php if ($db_is_information_schema || $tbl_is_view) { ?> 206 <th id="th<?php echo ++$i; ?>"><?php echo $strView; ?></th> 207 <?php } else { ?> 208 <th colspan="7" id="th<?php echo ++$i; ?>"><?php echo $strAction; ?></th> 209 <?php } ?> 210 </tr> 211 </thead> 212 <tbody> 213 <?php 214 unset($i); 215 216 217 // table body 218 219 // prepare comments 220 $comments_map = array(); 221 $mime_map = array(); 222 223 if ($GLOBALS['cfg']['ShowPropertyComments']) { 224 require_once './libraries/relation.lib.php'; 225 require_once './libraries/transformations.lib.php'; 226 227 $cfgRelation = PMA_getRelationsParam(); 228 229 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) { 230 $comments_map = PMA_getComments($db, $table); 231 232 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) { 233 $mime_map = PMA_getMIME($db, $table, true); 234 } 235 } 236 } 237 238 $rownum = 0; 239 $aryFields = array(); 240 $checked = (!empty($checkall) ? ' checked="checked"' : ''); 241 $save_row = array(); 242 $odd_row = true; 243 while ($row = PMA_DBI_fetch_assoc($fields_rs)) { 244 $save_row[] = $row; 245 $rownum++; 246 $aryFields[] = $row['Field']; 247 248 $type = $row['Type']; 249 // reformat mysql query output - staybyte - 9. June 2001 250 // loic1: set or enum types: slashes single quotes inside options 251 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) { 252 $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1); 253 $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')'; 254 255 // for the case ENUM('–','“') 256 $type = htmlspecialchars($type); 257 258 $type_nowrap = ''; 259 260 $binary = 0; 261 $unsigned = 0; 262 $zerofill = 0; 263 } else { 264 $type_nowrap = ' nowrap="nowrap"'; 265 // strip the "BINARY" attribute, except if we find "BINARY(" because 266 // this would be a BINARY or VARBINARY field type 267 if (!preg_match('@BINARY[\(]@i', $type)) { 268 $type = preg_replace('@BINARY@i', '', $type); 269 } 270 $type = preg_replace('@ZEROFILL@i', '', $type); 271 $type = preg_replace('@UNSIGNED@i', '', $type); 272 if (empty($type)) { 273 $type = ' '; 274 } 275 276 if (!preg_match('@BINARY[\(]@i', $row['Type'])) { 277 $binary = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary'); 278 } else { 279 $binary = false; 280 } 281 282 $unsigned = stristr($row['Type'], 'unsigned'); 283 $zerofill = stristr($row['Type'], 'zerofill'); 284 } 285 286 // rabus: Divide charset from the rest of the type definition (MySQL >= 4.1) 287 unset($field_charset); 288 if (PMA_MYSQL_INT_VERSION >= 40100) { 289 if ((substr($type, 0, 4) == 'char' 290 || substr($type, 0, 7) == 'varchar' 291 || substr($type, 0, 4) == 'text' 292 || substr($type, 0, 8) == 'tinytext' 293 || substr($type, 0, 10) == 'mediumtext' 294 || substr($type, 0, 8) == 'longtext' 295 || substr($type, 0, 3) == 'set' 296 || substr($type, 0, 4) == 'enum' 297 ) && !$binary) { 298 if (strpos($type, ' character set ')) { 299 $type = substr($type, 0, strpos($type, ' character set ')); 300 } 301 if (!empty($row['Collation'])) { 302 $field_charset = $row['Collation']; 303 } else { 304 $field_charset = ''; 305 } 306 } else { 307 $field_charset = ''; 308 } 309 } 310 311 // garvin: Display basic mimetype [MIME] 312 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) { 313 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']); 314 } else { 315 $type_mime = ''; 316 } 317 318 $attribute = ' '; 319 if ($binary) { 320 $attribute = 'BINARY'; 321 } 322 if ($unsigned) { 323 $attribute = 'UNSIGNED'; 324 } 325 if ($zerofill) { 326 $attribute = 'UNSIGNED ZEROFILL'; 327 } 328 329 // MySQL 4.1.2+ TIMESTAMP options 330 // (if on_update_current_timestamp is set, then it's TRUE) 331 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) { 332 $attribute = 'ON UPDATE CURRENT_TIMESTAMP'; 333 } 334 335 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the 336 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe 337 // the latter. 338 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']) { 339 $row['Null'] = ''; 340 } 341 342 343 if (!isset($row['Default'])) { 344 if ($row['Null'] == 'YES') { 345 $row['Default'] = '<i>NULL</i>'; 346 } 347 } else { 348 $row['Default'] = htmlspecialchars($row['Default']); 349 } 350 351 $field_encoded = urlencode($row['Field']); 352 $field_name = htmlspecialchars($row['Field']); 353 354 // garvin: underline commented fields and display a hover-title (CSS only) 355 356 $comment_style = ''; 357 if (isset($comments_map[$row['Field']])) { 358 $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>'; 359 } 360 361 if (isset($pk_array[$row['Field']])) { 362 $field_name = '<u>' . $field_name . '</u>'; 363 } 364 echo "\n"; 365 ?> 366 <tr class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>"> 367 <td align="center"> 368 <input type="checkbox" name="selected_fld[]" value="<?php echo $field_encoded; ?>" id="checkbox_row_<?php echo $rownum; ?>" <?php echo $checked; ?> /> 369 </td> 370 <th nowrap="nowrap"><label for="checkbox_row_<?php echo $rownum; ?>"><?php echo $field_name; ?></label></th> 371 <td<?php echo $type_nowrap; ?>><bdo dir="ltr" xml:lang="en"><?php echo $type; echo $type_mime; ?></bdo></td> 372 <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? ' <td>' . (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>') . '</td>' . "\n" : '' ?> 373 <td nowrap="nowrap" style="font-size: 70%"><?php echo $attribute; ?></td> 374 <td><?php echo (($row['Null'] == 'YES') ? $strYes : $strNo); ?></td> 375 <td nowrap="nowrap"><?php if (isset($row['Default'])) { echo $row['Default']; } ?></td> 376 <td nowrap="nowrap"><?php echo $row['Extra']; ?></td> 377 <td align="center"> 378 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote($strRows) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>"> 379 <?php echo $titles['BrowseDistinctValues']; ?></a> 380 </td> 381 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?> 382 <td align="center"> 383 <a href="tbl_alter.php?<?php echo $url_query; ?>&field=<?php echo $field_encoded; ?>"> 384 <?php echo $titles['Change']; ?></a> 385 </td> 386 <td align="center"> 387 <?php 388 // loic1: Drop field only if there is more than one field in the table 389 if ($fields_cnt > 1) { 390 echo "\n"; 391 ?> 392 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field'])); ?>&cpurge=1&purgekey=<?php echo urlencode($row['Field']); ?>&zero_rows=<?php echo urlencode(sprintf($strFieldHasBeenDropped, htmlspecialchars($row['Field']))); ?>" 393 onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')"> 394 <?php echo $titles['Drop']; ?></a> 395 <?php 396 } else { 397 echo "\n" . ' ' . $titles['NoDrop']; 398 } 399 echo "\n"; 400 ?> 401 </td> 402 <td align="center"> 403 <?php 404 if ($type == 'text' || $type == 'blob') { 405 echo $titles['NoPrimary'] . "\n"; 406 } else { 407 echo "\n"; 408 ?> 409 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . (empty($primary) ? '' : ' DROP PRIMARY KEY,') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAPrimaryKey, htmlspecialchars($row['Field']))); ?>" 410 onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . (empty($primary) ? '' : ' DROP PRIMARY KEY,'); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')"> 411 <?php echo $titles['Primary']; ?></a> 412 <?php 413 } 414 echo "\n"; 415 ?> 416 </td> 417 <td align="center"> 418 <?php 419 if ($type == 'text' || $type == 'blob') { 420 echo $titles['NoUnique'] . "\n"; 421 } else { 422 echo "\n"; 423 ?> 424 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>"> 425 <?php echo $titles['Unique']; ?></a> 426 <?php 427 } 428 echo "\n"; 429 ?> 430 </td> 431 <td align="center"> 432 <?php 433 if ($type == 'text' || $type == 'blob') { 434 echo $titles['NoIndex'] . "\n"; 435 } else { 436 echo "\n"; 437 ?> 438 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>"> 439 <?php echo $titles['Index']; ?></a> 440 <?php 441 } 442 echo "\n"; 443 ?> 444 </td> 445 <?php 446 if ((!empty($tbl_type) && $tbl_type == 'MYISAM') 447 && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'varchar'))) { 448 echo "\n"; 449 ?> 450 <td align="center" nowrap="nowrap"> 451 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>"> 452 <?php echo $titles['IdxFulltext']; ?></a> 453 </td> 454 <?php 455 } else { 456 echo "\n"; 457 ?> 458 <td align="center" nowrap="nowrap"> 459 <?php echo $titles['NoIdxFulltext'] . "\n"; ?> 460 </td> 461 <?php 462 } // end if... else... 463 echo "\n"; 464 } // end if (! $tbl_is_view && ! $db_is_information_schema) 465 ?> 466 </tr> 467 <?php 468 unset($field_charset); 469 } // end while 470 471 echo '</tbody>' . "\n" 472 .'</table>' . "\n"; 473 474 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table); 475 ?> 476 477 <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>" 478 width="38" height="22" alt="<?php echo $strWithChecked; ?>" /> 479 <a href="<?php echo $checkall_url; ?>&checkall=1" 480 onclick="if (markAllRows('fieldsForm')) return false;"> 481 <?php echo $strCheckAll; ?></a> 482 / 483 <a href="<?php echo $checkall_url; ?>" 484 onclick="if (unMarkAllRows('fieldsForm')) return false;"> 485 <?php echo $strUncheckAll; ?></a> 486 487 <i><?php echo $strWithChecked; ?></i> 488 489 <?php 490 if ($cfg['PropertiesIconic']) { 491 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', $strBrowse, 'b_browse.png'); 492 } else { 493 echo '<input type="submit" name="submit_mult" value="' . $strChange . '" title="' . $strChange . '" />' . "\n"; 494 } 495 if (! $tbl_is_view && ! $db_is_information_schema) { 496 if ($cfg['PropertiesIconic']) { 497 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $strChange, 'b_edit.png'); 498 // Drop button if there is at least two fields 499 if ($fields_cnt > 1) { 500 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', $strDrop, 'b_drop.png'); 501 } 502 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', $strPrimary, 'b_primary.png'); 503 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', $strUnique, 'b_unique.png'); 504 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', $strIndex, 'b_index.png'); 505 if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) { 506 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', $strIdxFulltext, 'b_ftext.png'); 507 } 508 } else { 509 // Drop button if there is at least two fields 510 if ($fields_cnt > 1) { 511 echo '<i>' . $strOr . '</i>' . "\n" 512 . '<input type="submit" name="submit_mult" value="' . $strDrop . '" title="' . $strDrop . '" />' . "\n"; 513 } 514 echo '<i>' . $strOr . '</i>' . "\n" 515 . '<input type="submit" name="submit_mult" value="' . $strPrimary . '" title="' . $strPrimary . '" />' . "\n"; 516 echo '<i>' . $strOr . '</i>' . "\n" 517 . '<input type="submit" name="submit_mult" value="' . $strIndex . '" title="' . $strIndex . '" />' . "\n"; 518 echo '<i>' . $strOr . '</i>' . "\n" 519 . '<input type="submit" name="submit_mult" value="' . $strUnique . '" title="' . $strUnique . '" />' . "\n"; 520 if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) { 521 echo '<i>' . $strOr . '</i>' . "\n" 522 . '<input type="submit" name="submit_mult" value="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' . "\n"; 523 } 524 } 525 } 526 ?> 527 </form> 528 <hr /> 529 530 <?php 531 /** 532 * Work on the table 533 */ 534 ?> 535 <a href="tbl_printview.php?<?php echo $url_query; ?>"><?php 536 if ($cfg['PropertiesIconic']) { 537 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . $strPrintView . '"/>'; 538 } 539 echo $strPrintView; 540 ?></a> 541 542 <?php 543 if (! $tbl_is_view && ! $db_is_information_schema) { 544 545 // if internal relations are available, or the table type is INNODB 546 // ($tbl_type comes from libraries/tbl_info.inc.php) 547 if ($cfgRelation['relwork'] || $tbl_type=="INNODB") { 548 ?> 549 <a href="tbl_relation.php?<?php echo $url_query; ?>"><?php 550 if ($cfg['PropertiesIconic']) { 551 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . $strRelationView . '"/>'; 552 } 553 echo $strRelationView; 554 ?></a> 555 <?php 556 } 557 ?> 558 <a href="sql.php?<?php echo $url_query; ?>&session_max_rows=all&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table) . ' PROCEDURE ANALYSE()'); ?>"><?php 559 if ($cfg['PropertiesIconic']) { 560 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . $strStructPropose . '" />'; 561 } 562 echo $strStructPropose; 563 ?></a><?php 564 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n"; 565 ?><br /> 566 <form method="post" action="tbl_addfield.php" 567 onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)"> 568 <?php 569 echo PMA_generate_common_hidden_inputs($db, $table); 570 if ($cfg['PropertiesIconic']) { 571 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . $strAddNewField . '"/>'; 572 } 573 echo sprintf($strAddFields, '<input type="text" name="num_fields" size="2" maxlength="2" value="1" style="vertical-align: middle" onfocus="this.select()" />'); 574 ?> 575 <input type="radio" name="field_where" id="radio_field_where_last" value="last" checked="checked" /><label for="radio_field_where_last"><?php echo $strAtEndOfTable; ?></label> 576 <input type="radio" name="field_where" id="radio_field_where_first" value="first" /><label for="radio_field_where_first"><?php echo $strAtBeginningOfTable; ?></label> 577 <input type="radio" name="field_where" id="radio_field_where_after" value="after" /><?php 578 $fieldOptions = '</label><select name="after_field" style="vertical-align: middle" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">'; 579 foreach ($aryFields as $fieldname) { 580 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n"; 581 } 582 unset($aryFields); 583 $fieldOptions .= '</select><label for="radio_field_where_after">'; 584 echo str_replace('<label for="radio_field_where_after"></label>', '', '<label for="radio_field_where_after">' . sprintf($strAfter, $fieldOptions) . '</label>') . "\n"; 585 ?> 586 <input type="submit" value="<?php echo $strGo; ?>" style="vertical-align: middle" /> 587 </form> 588 <hr /> 589 <?php 590 } 591 592 /** 593 * If there are more than 20 rows, displays browse/select/insert/empty/drop 594 * links again 595 */ 596 if ($fields_cnt > 20) { 597 require './libraries/tbl_links.inc.php'; 598 } // end if ($fields_cnt > 20) 599 echo "\n\n"; 600 601 /** 602 * Displays indexes 603 */ 604 echo '<div id="tablestatistics">' . "\n"; 605 if (! $tbl_is_view && ! $db_is_information_schema) { 606 define('PMA_IDX_INCLUDED', 1); 607 require './tbl_indexes.php'; 608 } 609 610 /** 611 * Displays Space usage and row statistics 612 */ 613 // BEGIN - Calc Table Space - staybyte - 9 June 2001 614 // loic1, 22 feb. 2002: updated with patch from 615 // Joshua Nye <josh at boxcarmedia.com> to get valid 616 // statistics whatever is the table type 617 if ($cfg['ShowStats']) { 618 $nonisam = false; 619 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB'); 620 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) { 621 $nonisam = true; 622 } 623 624 // Gets some sizes 625 $mergetable = false; 626 if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') { 627 $mergetable = true; 628 } 629 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length']); 630 if ($mergetable == false) { 631 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length']); 632 } 633 if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) { 634 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free']); 635 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free']); 636 } else { 637 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']); 638 } 639 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']); 640 if ($table_info_num_rows > 0) { 641 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1); 642 } 643 644 // Displays them 645 $odd_row = false; 646 ?> 647 648 <a name="showusage"></a> 649 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?> 650 <table id="tablespaceusage" class="data"> 651 <caption class="tblHeaders"><?php echo $strSpaceUsage; ?></caption> 652 <thead> 653 <tr> 654 <th><?php echo $strType; ?></th> 655 <th colspan="2"><?php echo $strUsage; ?></th> 656 </tr> 657 </thead> 658 <tbody> 659 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 660 <th class="name"><?php echo $strData; ?></th> 661 <td class="value"><?php echo $data_size; ?></td> 662 <td class="unit"><?php echo $data_unit; ?></td> 663 </tr> 664 <?php 665 if (isset($index_size)) { 666 ?> 667 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 668 <th class="name"><?php echo $strIndex; ?></th> 669 <td class="value"><?php echo $index_size; ?></td> 670 <td class="unit"><?php echo $index_unit; ?></td> 671 </tr> 672 <?php 673 } 674 if (isset($free_size)) { 675 ?> 676 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning"> 677 <th class="name"><?php echo $strOverhead; ?></th> 678 <td class="value"><?php echo $free_size; ?></td> 679 <td class="unit"><?php echo $free_unit; ?></td> 680 </tr> 681 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 682 <th class="name"><?php echo $strEffective; ?></th> 683 <td class="value"><?php echo $effect_size; ?></td> 684 <td class="unit"><?php echo $effect_unit; ?></td> 685 </tr> 686 <?php 687 } 688 if (isset($tot_size) && $mergetable == false) { 689 ?> 690 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 691 <th class="name"><?php echo $strTotalUC; ?></th> 692 <td class="value"><?php echo $tot_size; ?></td> 693 <td class="unit"><?php echo $tot_unit; ?></td> 694 </tr> 695 <?php 696 } 697 // Optimize link if overhead 698 if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'BDB')) { 699 ?> 700 <tr class="tblFooters"> 701 <td colspan="3" align="center"> 702 <a href="sql.php?<?php echo $url_query; ?>&pos=0&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php 703 if ($cfg['PropertiesIconic']) { 704 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . $strOptimizeTable. '" />'; 705 } 706 echo $strOptimizeTable; 707 ?></a> 708 </td> 709 </tr> 710 <?php 711 } 712 ?> 713 </tbody> 714 </table> 715 <?php 716 } 717 $odd_row = false; 718 ?> 719 <table id="tablerowstats" class="data"> 720 <caption class="tblHeaders"><?php echo $strRowsStatistic; ?></caption> 721 <thead> 722 <tr> 723 <th><?php echo $strStatement; ?></th> 724 <th><?php echo $strValue; ?></th> 725 </tr> 726 </thead> 727 <tbody> 728 <?php 729 if (isset($showtable['Row_format'])) { 730 ?> 731 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 732 <th class="name"><?php echo $strFormat; ?></th> 733 <td class="value"><?php 734 if ($showtable['Row_format'] == 'Fixed') { 735 echo $strFixed; 736 } elseif ($showtable['Row_format'] == 'Dynamic') { 737 echo $strDynamic; 738 } else { 739 echo $showtable['Row_format']; 740 } 741 ?></td> 742 </tr> 743 <?php 744 } 745 if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($tbl_collation)) { 746 ?> 747 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 748 <th class="name"><?php echo $strCollation; ?></th> 749 <td class="value"><?php 750 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>'; 751 ?></td> 752 </tr> 753 <?php 754 } 755 if (!$is_innodb && isset($showtable['Rows'])) { 756 ?> 757 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 758 <th class="name"><?php echo $strRows; ?></th> 759 <td class="value"><?php echo PMA_formatNumber($showtable['Rows'], 0); ?></td> 760 </tr> 761 <?php 762 } 763 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) { 764 ?> 765 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 766 <th class="name"><?php echo $strRowLength; ?> ø</th> 767 <td class="value"><?php echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?></td> 768 </tr> 769 <?php 770 } 771 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) { 772 ?> 773 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 774 <th class="name"><?php echo $strRowSize; ?> ø</th> 775 <td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td> 776 </tr> 777 <?php 778 } 779 if (isset($showtable['Auto_increment'])) { 780 ?> 781 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 782 <th class="name"><?php echo $strNext; ?> Autoindex</th> 783 <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td> 784 </tr> 785 <?php 786 } 787 if (isset($showtable['Create_time'])) { 788 ?> 789 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 790 <th class="name"><?php echo $strStatCreateTime; ?></th> 791 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td> 792 </tr> 793 <?php 794 } 795 if (isset($showtable['Update_time'])) { 796 ?> 797 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 798 <th class="name"><?php echo $strStatUpdateTime; ?></th> 799 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td> 800 </tr> 801 <?php 802 } 803 if (isset($showtable['Check_time'])) { 804 ?> 805 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> 806 <th class="name"><?php echo $strStatCheckTime; ?></th> 807 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td> 808 </tr> 809 <?php 810 } 811 ?> 812 </tbody> 813 </table> 814 <?php 815 } 816 // END - Calc Table Space 817 echo '<div class="clearfloat"></div>' . "\n"; 818 echo '</div>' . "\n"; 819 820 /** 821 * Displays the footer 822 */ 823 require_once './libraries/footer.inc.php'; 824 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Mon Nov 26 15:18:20 2007 | par Balluche grâce à PHPXref 0.7 |
|