3 // vim: expandtab sw=4 ts=4 sts=4:
7 * Prepares the tables list if the user where not redirected to this script
8 * because there is no table in the database ($is_info is TRUE)
10 if (empty($is_info)) {
11 include('./db_details_common.php3');
12 $url_query .= '&goto=db_details_structure.php3';
14 // Drops/deletes multiple tables if required
15 if ((!empty($submit_mult) && isset($selected_tbl))
16 ||
isset($mult_btn)) {
17 $action = 'db_details_structure.php3';
18 include('./mult_submits.inc.php3');
21 // Gets the database structure
22 $sub_part = '_structure';
23 include('./db_details_db_info.php3');
29 * Settings for relations stuff
31 require('./libraries/relation.lib.php3');
32 $cfgRelation = PMA_getRelationsParam();
35 * Check if comments were updated
37 if ($cfgRelation['commwork'] && isset($db_comment) && $db_comment == 'true') {
38 PMA_SetComment($db, '', '(db_comment)', $comment);
42 * Displays the tables list
50 if ($num_tables == 0) {
51 echo $strNoTablesFound . "\n";
54 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
55 else if (PMA_MYSQL_INT_VERSION
>= 32303) {
57 // Get additional information about tables for tooltip
58 if ($cfg['ShowTooltip']) {
59 $tooltip_truename = array();
60 $tooltip_aliasname = array();
62 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
63 while ($tmp = PMA_mysql_fetch_array($result)) {
64 $tooltip_truename[$tmp['Name']] = ($cfg['ShowTooltipAliasTB'] ?
(!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : $tmp['Name']) : $tmp['Name']);
65 $tooltip_aliasname[$tmp['Name']] = ($cfg['ShowTooltipAliasTB'] ?
$tmp['Name'] : (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : ''));
66 if (isset($tmp['Create_time']) && !empty($tmp['Create_time'])) {
67 $tooltip_aliasname[$tmp['Name']] .= ', ' . $strStatCreateTime . ': ' . PMA_localisedDate(strtotime($tmp['Create_time']));
70 if (isset($tmp['Update_time']) && !empty($tmp['Update_time'])) {
71 $tooltip_aliasname[$tmp['Name']] .= ', ' . $strStatUpdateTime . ': ' . PMA_localisedDate(strtotime($tmp['Update_time']));
74 if (isset($tmp['Check_time']) && !empty($tmp['Check_time'])) {
75 $tooltip_aliasname[$tmp['Name']] .= ', ' . $strStatCheckTime . ': ' . PMA_localisedDate(strtotime($tmp['Check_time']));
81 if ($cfgRelation['commwork']) {
82 $comment = PMA_getComments($db);
85 * Displays table comment
87 if (is_array($comment)) {
91 <?php
echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?
>
97 <form method
="post" action
="db_details_structure.php3" name
="tablesForm">
98 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
100 <table border
="<?php echo $cfg['Border']; ?>">
103 <th
> 
;<?php
echo $strTable; ?
> 
;</th
>
104 <th colspan
="6"><?php
echo $strAction; ?
></th
>
105 <th
><?php
echo $strRecords; ?
></th
>
106 <th
><?php
echo $strType; ?
></th
>
108 if ($cfg['ShowStats']) {
109 echo '<th>' . $strSize . '</th>';
115 $i = $sum_entries = 0;
116 (double) $sum_size = 0;
117 $checked = (!empty($checkall) ?
' checked="checked"' : '');
118 while (list($keyname, $sts_data) = each($tables)) {
119 $table = $sts_data['Name'];
120 $table_encoded = urlencode($table);
121 $table_name = htmlspecialchars($table);
123 $alias = (!empty($tooltip_aliasname) && isset($tooltip_aliasname[$table]))
124 ?
str_replace('"', '"', $tooltip_aliasname[$table])
125 : htmlspecialchars($sts_data['Name']);
126 $truename = (!empty($tooltip_truename) && isset($tooltip_truename[$table]))
127 ?
str_replace('"', '"', $tooltip_truename[$table])
128 : htmlspecialchars($sts_data['Name']);
130 // Sets parameters for links
131 $tbl_url_query = $url_query . '&table=' . $table_encoded;
132 $bgcolor = ($i++ %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
136 <td align
="center" bgcolor
="<?php echo $bgcolor; ?>">
137 <input type
="checkbox" name
="selected_tbl[]" value
="<?php echo $table_encoded; ?>" id
="checkbox_tbl_<?php echo $i; ?>"<?php
echo $checked; ?
> />
139 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
140  
;<b
><label
for="checkbox_tbl_<?php echo $i; ?>" title
="<?php echo $alias; ?>"><?php
echo $truename; ?
></label
> 
;</b
> 
;
142 <td bgcolor
="<?php echo $bgcolor; ?>">
144 include('./libraries/bookmark.lib.php3');
145 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
147 if (!empty($sts_data['Rows'])) {
148 echo '<a href="sql.php3?' . $tbl_url_query . '&sql_query='
149 . (isset($book_sql_query) && $book_sql_query != FALSE ?
urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table)))
150 . '&pos=0">' . $strBrowse . '</a>';
156 <td bgcolor
="<?php echo $bgcolor; ?>">
158 if (!empty($sts_data['Rows'])) {
159 echo '<a href="tbl_select.php3?' . $tbl_url_query . '">'
160 . $strSelect . '</a>';
166 <td bgcolor
="<?php echo $bgcolor; ?>">
167 <a href
="tbl_change.php3?<?php echo $tbl_url_query; ?>">
168 <?php
echo $strInsert; ?
></a
>
170 <td bgcolor
="<?php echo $bgcolor; ?>">
171 <a href
="tbl_properties_structure.php3?<?php echo $tbl_url_query; ?>">
172 <?php
echo $strProperties; ?
></a
>
174 <td bgcolor
="<?php echo $bgcolor; ?>">
175 <a href
="sql.php3?<?php echo $tbl_url_query; ?>&reload=1&purge=1&sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table))); ?>"
176 onclick
="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
177 <?php
echo $strDrop; ?
></a
>
179 <td bgcolor
="<?php echo $bgcolor; ?>">
181 if (!empty($sts_data['Rows'])) {
182 echo '<a href="sql.php3?' . $tbl_url_query
184 if (PMA_MYSQL_INT_VERSION
>= 40000) {
185 echo urlencode('TRUNCATE ' . PMA_backquote($table))
187 . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
188 . '" onclick="return confirmLink(this, \'TRUNCATE ';
190 echo urlencode('DELETE FROM ' . PMA_backquote($table))
192 . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
193 . '" onclick="return confirmLink(this, \'DELETE FROM ';
195 echo PMA_jsFormat($table) . '\')">' . $strEmpty . '</a>';
204 // loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid
205 // statistics whatever is the table type
206 if (isset($sts_data['Rows'])) {
207 // MyISAM, ISAM or Heap table: Row count, data size and index size
209 if (isset($sts_data['Type']) && ereg('^(MyISAM|ISAM|HEAP)$', $sts_data['Type'])) {
210 if ($cfg['ShowStats']) {
211 $tblsize = doubleval($sts_data['Data_length']) +
doubleval($sts_data['Index_length']);
212 $sum_size +
= $tblsize;
213 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ?
1 : 0);
215 $sum_entries +
= $sts_data['Rows'];
216 $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
219 // InnoDB table: Row count is not accurate but data and index
221 else if (isset($sts_data['Type']) && $sts_data['Type'] == 'InnoDB') {
222 if ($cfg['ShowStats']) {
223 $tblsize = $sts_data['Data_length'] +
$sts_data['Index_length'];
224 $sum_size +
= $tblsize;
225 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ?
1 : 0);
227 //$display_rows = ' - ';
228 // get row count with another method
229 $local_query = 'SELECT COUNT(*) AS count FROM '
230 . PMA_backquote($db) . '.'
231 . PMA_backquote($table);
232 $table_info_result = PMA_mysql_query($local_query)
233 or PMA_mysqlDie('', $local_query, '', $err_url_0);
234 $row_count = PMA_mysql_result($table_info_result, 0, 'count');
235 $sum_entries +
= $row_count;
236 $display_rows = number_format($row_count, 0, $number_decimal_separator, $number_thousands_separator);
239 // Merge or BerkleyDB table: Only row count is accurate.
240 else if (isset($sts_data['Type']) && ereg('^(MRG_MyISAM|BerkeleyDB)$', $sts_data['Type'])) {
241 if ($cfg['ShowStats']) {
242 $formated_size = ' - ';
245 $sum_entries +
= $sts_data['Rows'];
246 $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
249 // Unknown table type.
251 if ($cfg['ShowStats']) {
252 $formated_size = 'unknown';
255 $display_rows = 'unknown';
258 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
260 echo "\n" . ' ' . $display_rows . "\n";
263 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
264  
;<?php
echo (isset($sts_data['Type']) ?
$sts_data['Type'] : ' '); ?
> 
;
267 if ($cfg['ShowStats']) {
270 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
272 <a href
="tbl_properties_structure.php3?<?php echo $tbl_url_query; ?>#showusage"><?php
echo $formated_size . ' ' . $unit; ?
></a
>
279 <td colspan
="3" align
="center" bgcolor
="<?php echo $bgcolor; ?>">
280 <?php
echo $strInUse . "\n"; ?
>
290 if ($cfg['ShowStats']) {
291 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
297 <th align
="center" nowrap
="nowrap">
298  
;<b
><?php
echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?
></b
> 
;
300 <th colspan
="6" align
="center">
301 <b
><?php
echo $strSum; ?
></b
>
303 <th align
="right" nowrap
="nowrap">
304 <b
><?php
echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?
></b
>
310 if ($cfg['ShowStats']) {
313 <th align
="right" nowrap
="nowrap">
315 <b
><?php
echo $sum_formated . ' ' . $unit; ?
></b
>
324 // Check all tables url
325 $checkall_url = 'db_details_structure.php3?' . PMA_generate_common_url($db);
329 <td colspan
="<?php echo (($cfg['ShowStats']) ? '11' : '10'); ?>" valign
="bottom">
330 <img src
="./images/arrow_<?php echo $text_dir; ?>.gif" border
="0" width
="38" height
="22" alt
="<?php echo $strWithChecked; ?>" />
331 <a href
="<?php echo $checkall_url; ?>&checkall=1" onclick
="setCheckboxes('tablesForm', true); return false;">
332 <?php
echo $strCheckAll; ?
></a
>
334 <a href
="<?php echo $checkall_url; ?>" onclick
="setCheckboxes('tablesForm', false); return false;">
335 <?php
echo $strUncheckAll; ?
></a
>
337 <img src
="./images/spacer.gif" border
="0" width
="38" height
="1" alt
="" />
338 <select name
="submit_mult" dir
="ltr" onchange
="this.form.submit();">
341 echo ' <option value="' . $strWithChecked . '" selected="selected">'
342 . $strWithChecked . '</option>' . "\n";
343 echo ' <option value="' . $strDrop . '" >'
344 . $strDrop . '</option>' . "\n";
345 echo ' <option value="' . $strEmpty . '" >'
346 . $strEmpty . '</option>' . "\n";
347 echo ' <option value="' . $strPrintView . '" >'
348 . $strPrintView . '</option>' . "\n";
349 echo ' <option value="' . $strOptimizeTable . '" >'
350 . $strOptimizeTable . '</option>' . "\n";
351 echo ' <option value="' . $strRepairTable . '" >'
352 . $strRepairTable . '</option>' . "\n";
355 <script type
="text/javascript" language
="javascript">
357 // Fake js to allow the use of the <noscript> tag
361 <input type
="submit" value
="<?php echo $strGo; ?>" />
369 } // end case mysql >= 3.23.03
371 // 3. Shows tables list mysql < 3.23.03
373 if ($cfgRelation['commwork']) {
374 $comment = PMA_getComments($db);
377 * Displays table comment
379 if (is_array($comment)) {
383 <?php
echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?
>
392 <form action
="db_details_structure.php3">
393 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
395 <table border
="<?php echo $cfg['Border']; ?>">
398 <th
> 
;<?php
echo $strTable; ?
> 
;</th
>
399 <th colspan
="6"><?php
echo $strAction; ?
></th
>
400 <th
><?php
echo $strRecords; ?
></th
>
403 $checked = (!empty($checkall) ?
' checked="checked"' : '');
404 while ($i < $num_tables) {
405 $table = $tables[$i];
406 $table_encoded = urlencode($table);
407 $table_name = htmlspecialchars($table);
409 // Sets parameters for links
410 $tbl_url_query = $url_query . '&table=' . $table_encoded;
411 $bgcolor = ($i %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
415 <td align
="center" bgcolor
="<?php echo $bgcolor; ?>">
416 <input type
="checkbox" name
="selected_tbl[]" value
="<?php echo $table_encoded; ?>" id
="checkbox_tbl_<?php echo $i; ?>"<?php
echo $checked; ?
> />
418 <td bgcolor
="<?php echo $bgcolor; ?>" class="data">
419 <b
> 
;<label
for="checkbox_tbl_<?php echo $i; ?>"><?php
echo $table_name; ?
></label
> 
;</b
>
421 <td bgcolor
="<?php echo $bgcolor; ?>">
422 <a href
="sql.php3?<?php echo $tbl_url_query; ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&pos=0"><?php
echo $strBrowse; ?
></a
>
424 <td bgcolor
="<?php echo $bgcolor; ?>">
425 <a href
="tbl_select.php3?<?php echo $tbl_url_query; ?>"><?php
echo $strSelect; ?
></a
>
427 <td bgcolor
="<?php echo $bgcolor; ?>">
428 <a href
="tbl_change.php3?<?php echo $tbl_url_query; ?>"><?php
echo $strInsert; ?
></a
>
430 <td bgcolor
="<?php echo $bgcolor; ?>">
431 <a href
="tbl_properties.php3?<?php echo $tbl_url_query; ?>"><?php
echo $strProperties; ?
></a
>
433 <td bgcolor
="<?php echo $bgcolor; ?>">
434 <a href
="sql.php3?<?php echo $tbl_url_query; ?>&reload=1&purge=1&sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, $table_name)); ?>"><?php
echo $strDrop; ?
></a
>
436 <td bgcolor
="<?php echo $bgcolor; ?>">
437 <a href
="sql.php3?<?php echo $tbl_url_query; ?>&sql_query=<?php echo urlencode('DELETE FROM ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenEmptied, $table_name)); ?>"><?php
echo $strEmpty; ?
></a
>
439 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
440 <?php
PMA_countRecords($db, $table); echo "\n"; ?
>
448 // Check all tables url
449 $checkall_url = 'db_details_structure.php3?' . PMA_generate_common_url($db);
453 <img src
="./images/arrow_<?php echo $text_dir; ?>.gif" border
="0" width
="38" height
="22" alt
="<?php echo $strWithChecked; ?>" />
454 <a href
="<?php echo $checkall_url; ?>&checkall=1" onclick
="setCheckboxes('tablesForm', true); return false;">
455 <?php
echo $strCheckAll; ?
></a
>
457 <a href
="<?php echo $checkall_url; ?>" onclick
="setCheckboxes('tablesForm', false); return false;">
458 <?php
echo $strUncheckAll; ?
></a
>
464 <img src
="./images/spacer.gif" border
="0" width
="38" height
="1" alt
="" />
465 <i
><?php
echo $strWithChecked; ?
></i
> 
; 
;
466 <input type
="submit" name
="submit_mult" value
="<?php echo $strDrop; ?>" />
467  
;<?php
$strOr . "\n"; ?
> 
;
468 <input type
="submit" name
="submit_mult" value
="<?php echo $strEmpty; ?>" />
475 } // end case mysql < 3.23.03
484 * Work on the database
487 <!-- DATABASE WORK
-->
491 if ($num_tables > 0) {
493 <!-- Printable view of a table
-->
495 <div style
="margin-bottom: 10px"><a href
="db_printview.php3?<?php echo $url_query; ?>"><?php
echo $strPrintView; ?
></a
></div
>
498 <div style
="margin-bottom: 10px"><a href
="./db_datadict.php3?<?php echo $url_query; ?>"><?php
echo $strDataDict; ?
></a
></div
>
505 if ($cfgRelation['commwork']) {
507 <!-- Alter
/Enter db
-comment
-->
509 <form method
="post" action
="db_details_structure.php3">
510 <?php
echo $strDBComment; ?
>
511 <input type
="hidden" name
="db_comment" value
="true" />
512 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
513 <input type
="text" name
="comment" class="textfield" value
="<?php echo (isset($comment) && is_array($comment) ? htmlspecialchars(implode(' ', $comment)) : ''); ?>" />
514 <input type
="submit" value
="<?php echo $strGo; ?>" />
521 <!-- Create a
new table
-->
523 <form method
="post" action
="tbl_create.php3"
524 onsubmit
="return (emptyFormElements(this, 'table') && checkFormElementInRange(this, 'num_fields', 1))">
525 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
527 echo ' ' . sprintf($strCreateNewTable, htmlspecialchars($db)) . ' :<br />' . "\n";
528 echo ' ' . $strName . ' : ' . "\n";
529 echo ' ' . '<input type="text" name="table" maxlength="64" class="textfield" />' . "\n";
530 echo ' ' . '<br />' . "\n";
531 echo ' ' . $strFields . ' : ' . "\n";
532 echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
533 echo ' ' . ' <input type="submit" value="' . $strGo . '" />' . "\n";
540 && !$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == FALSE) {
542 echo ' <div style="margin-bottom: 10px">' . "\n";
543 echo ' <font color="red">' . $strError . '</font><br />' . "\n";
544 $url_to_goto = '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php3?' . $url_query . '">';
545 echo ' ' . sprintf($strRelationNotWorking, $url_to_goto, '</a>') . "\n";
546 echo ' </div>' . "\n";
547 echo ' </li>' . "\n";
550 // is this OK to check for 'class' support?
551 $takeaway = $url_query . '&table=' . urlencode($table);
552 if ($cfgRelation['pdfwork'] && $num_tables > 0) {
554 <!-- Work on PDF Pages
-->
556 <div style
="margin-bottom: 10px"><a href
="pdf_pages.php3?<?php echo $takeaway; ?>"><?php
echo $strEditPDFPages; ?
></a
></div
>
561 // We only show this if we find something in the new pdf_pages table
563 $test_query = 'SELECT * FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
564 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
565 $test_rs = PMA_query_as_cu($test_query);
566 if ($test_rs && mysql_num_rows($test_rs) > 0) {
570 <form method
="post" action
="pdf_schema.php3">
571 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
572 <?php
echo $strDisplayPDF; ?
> 
;:<br
/>
573 <?php
echo $strPageNumber; ?
> 
;
574 <select name
="pdf_page_number">
576 while ($pages = @PMA_mysql_fetch_array
($test_rs)) {
578 . '<option value="' . $pages['page_nr'] . '">' . $pages['page_nr'] . ': ' . $pages['page_descr'] . '</option>';
583 <input type
="checkbox" name
="show_grid" id
="show_grid_opt" />
584 <label
for="show_grid_opt"><?php
echo $strShowGrid; ?
></label
><br
/>
585 <input type
="checkbox" name
="show_color" id
="show_color_opt" checked
="checked" />
586 <label
for="show_color_opt"><?php
echo $strShowColor; ?
></label
><br
/>
587 <input type
="checkbox" name
="show_table_dimension" id
="show_table_dim_opt" />
588 <label
for="show_table_dim_opt"><?php
echo $strShowTableDimension; ?
></label
><br
/>
589 <input type
="checkbox" name
="all_tab_same_wide" id
="all_tab_same_wide" />
590 <label
for="all_tab_same_wide"><?php
echo $strAllTableSameWidth; ?
></label
> <br
/>
591 <input type
="checkbox" name
="with_doc" id
="with_doc" checked
="checked" />
592 <label
for="with_doc"><?php
echo $strDataDict; ?
></label
> <br
/>
593 <?php
echo $strShowDatadictAs; ?
>
594 <select name
="orientation">
595 <option value
="L"><?php
echo $strLandscape;?
></option
>
596 <option value
="P"><?php
echo $strPortrait;?
></option
>
598  
; 
;<input type
="submit" value
="<?php echo $strGo; ?>" />
606 && $cfgRelation['relwork'] && $cfgRelation['commwork']) {
608 <!-- import docSQL files
-->
610 <div style
="margin-bottom: 10px"><a href
="db_details_importdocsql.php3?<?php echo $takeaway . '">' . $strImportDocSQL; ?></a></div>
618 * Displays the footer
621 require('./footer
.inc
.php3
');