diff options
author | Michal Čihař <mcihar@suse.cz> | 2011-08-04 19:14:36 +0400 |
---|---|---|
committer | Michal Čihař <mcihar@suse.cz> | 2011-08-04 19:15:06 +0400 |
commit | addeffabafb2fc1590559dc66cf0fb84573a338d (patch) | |
tree | f8940f5f11de5841000c1fe70cb6d57c3c92f3c8 /tbl_printview.php | |
parent | 57ab1b3e20ea680f33d8c4e856e595d3edcc0b18 (diff) |
Use standard field processing machinery
Diffstat (limited to 'tbl_printview.php')
-rw-r--r-- | tbl_printview.php | 47 |
1 files changed, 7 insertions, 40 deletions
diff --git a/tbl_printview.php b/tbl_printview.php index 9b7e7ff4de..068cfbc743 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -51,7 +51,7 @@ PMA_DBI_select_db($db); /** - * Multi-tables printview + * Multi-tables printview */ if (isset($selected_tbl) && is_array($selected_tbl)) { $the_tables = $selected_tbl; @@ -98,10 +98,7 @@ foreach ($the_tables as $key => $table) { /** * 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); + $columns = PMA_DBI_get_columns($db, $table); // We need this to correctly learn if a TIMESTAMP is NOT NULL, since @@ -155,40 +152,11 @@ foreach ($the_tables as $key => $table) { </thead> <tbody> <?php - while ($row = PMA_DBI_fetch_assoc($result)) { - $type = $row['Type']; - // reformat mysql query output - // 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]) . ')'; - - $binary = 0; - $unsigned = 0; - $zerofill = 0; - } else { - $type = preg_replace('@BINARY@i', '', $type); - $type = preg_replace('@ZEROFILL@i', '', $type); - $type = preg_replace('@UNSIGNED@i', '', $type); - if (empty($type)) { - $type = ' '; - } + foreach ($columns as $row) { + $extracted_fieldspec = PMA_extractFieldSpec($row['Type']); + $type = $extracted_fieldspec['print_type']; + $attribute = $extracted_fieldspec['attribute']; - $binary = stristr($row['Type'], 'binary'); - $unsigned = stristr($row['Type'], 'unsigned'); - $zerofill = stristr($row['Type'], 'zerofill'); - } - $attribute = ' '; - if ($binary) { - $attribute = 'BINARY'; - } - if ($unsigned) { - $attribute = 'UNSIGNED'; - } - if ($zerofill) { - $attribute = 'UNSIGNED ZEROFILL'; - } if (! isset($row['Default'])) { if ($row['Null'] != '' && $row['Null'] != 'NO') { $row['Default'] = '<i>NULL</i>'; @@ -252,8 +220,7 @@ foreach ($the_tables as $key => $table) { ?> </tr> <?php - } // end while - PMA_DBI_free_result($result); + } // end foreach ?> </tbody> </table> |