From 416277f3980f1bb56a513a106d28dbf4c902dee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 4 Aug 2011 17:16:03 +0200 Subject: [PATCH] Use standard field processing machinery --- .../schema/Pdf_Relation_Schema.class.php | 45 +++---------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index ec03d372d6..6fd1976941 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -1176,8 +1176,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema /** * 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); // Check if we can use Relations if (!empty($cfgRelation['relation'])) { // Find which tables are related with the current one and write it in @@ -1259,41 +1258,10 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema } $pdf->SetFont($this->_ff, ''); - 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]) . ')'; - $type_nowrap = ''; - - $binary = 0; - $unsigned = 0; - $zerofill = 0; - } else { - $type_nowrap = ' nowrap="nowrap"'; - $type = preg_replace('@BINARY@i', '', $type); - $type = preg_replace('@ZEROFILL@i', '', $type); - $type = preg_replace('@UNSIGNED@i', '', $type); - if (empty($type)) { - $type = ' '; - } - - $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'; - } + foreach ($columns as $row) { + $extracted_fieldspec = PMA_extractFieldSpec($row['Type']); + $type = $extracted_fieldspec['print_type']; + $attribute = $extracted_fieldspec['attribute']; if (! isset($row['Default'])) { if ($row['Null'] != '' && $row['Null'] != 'NO') { $row['Default'] = 'NULL'; @@ -1325,9 +1293,8 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema unset($links[6]); } $pdf->Row($pdf_row, $links); - } // end while + } // end foreach $pdf->SetFont($this->_ff, '', 14); - PMA_DBI_free_result($result); } //end each } }