diff --git a/htdocs/sql/tbl_printview.php b/htdocs/sql/tbl_printview.php new file mode 100755 --- /dev/null +++ b/htdocs/sql/tbl_printview.php @@ -0,0 +1,560 @@ + 1); + +if ($multi_tables) { + if (empty($GLOBALS['is_header_sent'])) { + require_once './libraries/header.inc.php'; + } + $tbl_list = ''; + foreach ($the_tables as $key => $table) { + $tbl_list .= (empty($tbl_list) ? '' : ', ') + . PMA_backquote(urldecode($table)); + } + echo ''. $strShowTables . ': ' . $tbl_list . '' . "\n"; + echo '
' . "\n"; +} // end if + +$tables_cnt = count($the_tables); +$counter = 0; + +foreach ($the_tables as $key => $table) { + $table = urldecode($table); + if ($counter + 1 >= $tables_cnt) { + $breakstyle = ''; + } else { + $breakstyle = ' style="page-break-after: always;"'; + } + $counter++; + echo '' . "\n"; + echo '

' . $table . '

' . "\n"; + + /** + * Gets table informations + */ + $result = PMA_DBI_query( + 'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, true) . '\';'); + $showtable = PMA_DBI_fetch_assoc($result); + $num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); + $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : ''); + PMA_DBI_free_result($result); + + $tbl_is_view = PMA_Table::isView($db, $table); + + // Gets table keys and store them in arrays + $indexes = array(); + $indexes_info = array(); + $indexes_data = array(); + $ret_keys = PMA_get_indexes($table, $err_url_0); + + PMA_extract_indexes($ret_keys, $indexes, $indexes_info, $indexes_data); + + /** + * Gets fields properties + */ + $result = PMA_DBI_query( + 'SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, + PMA_DBI_QUERY_STORE); + $fields_cnt = PMA_DBI_num_rows($result); + + +// We need this to correctly learn if a TIMESTAMP is NOT NULL, since +// SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL +// and SHOW CREATE TABLE says NOT NULL (tested +// in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910). + + $show_create_table = PMA_DBI_fetch_value( + 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), + 0, 1); + $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table)); + + // Check if we can use Relations (Mike Beck) + if (!empty($cfgRelation['relation'])) { + // Find which tables are related with the current one and write it in + // an array + $res_rel = PMA_getForeigners($db, $table); + + if (count($res_rel) > 0) { + $have_rel = true; + } else { + $have_rel = false; + } + } else { + $have_rel = false; + } // end if + + + /** + * Displays the comments of the table if MySQL >= 3.23 + */ + if (!empty($show_comment)) { + echo $strTableComments . ': ' . htmlspecialchars($show_comment) . '

'; + } + + /** + * Displays the table structure + */ + ?> + + + + + + + + + + + + ' . $strLinksTo . '' . "\n"; + } + if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) { + echo ' ' . "\n"; + } + if ($cfgRelation['mimework']) { + echo ' ' . "\n"; + } + ?> + + + + NULL'; + } + } else { + $row['Default'] = htmlspecialchars($row['Default']); + } + $field_name = htmlspecialchars($row['Field']); + + // 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. + /** + * @todo merge this logic with the one in tbl_structure.php + * or move it in a function similar to PMA_DBI_get_columns_full() + * but based on SHOW CREATE TABLE because information_schema + * cannot be trusted in this case (MySQL bug) + */ + if (!empty($analyzed_sql[0]['create_table_fields'][$field_name]['type']) && $analyzed_sql[0]['create_table_fields'][$field_name]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$field_name]['timestamp_not_null']) { + $row['Null'] = ''; + } + ?> + + + + + + + + '; + if (isset($res_rel[$field_name])) { + echo htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field']); + } + echo ' ' . "\n"; + } + if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) { + echo ' ' . "\n"; + } + if ($cfgRelation['mimework']) { + $mime_map = PMA_getMIME($db, $table, true); + + echo ' ' . "\n"; + } + ?> + + + +
' . $strComments . 'MIME
+ ' . $field_name . '' . "\n"; + } else { + echo ' ' . $field_name . "\n"; + } + ?> +   '; + $comments = PMA_getComments($db, $table); + if (isset($comments[$field_name])) { + echo htmlspecialchars($comments[$field_name]); + } + echo ' '; + if (isset($mime_map[$field_name])) { + echo htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])); + } + echo ' 
+ + 0) { + echo "\n"; + ?> +

+ + + + + + + + + + + +
+ 0) { + list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free']); + list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free']); + } else { + unset($free_size); + unset($free_unit); + list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']); + } + list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']); + if ($num_rows > 0) { + list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1); + } + + // Displays them + ?> +

+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
  + + + + + + + + + + + + + + + + + 0) { + ?> + + + + + 0 && $mergetable == false) { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
 ø + +
 ø + +
 Autoindex + +
+ +
+ +
+ +
+
+ + ' . "\n"; + } // end if + echo '' . "\n"; + +} // end while + +/** + * Displays the footer + */ +?> + + + + + +