Use standard field processing machinery

This commit is contained in:
Michal Čihař 2011-08-04 17:16:03 +02:00
parent addeffabaf
commit 416277f398

View File

@ -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
}
}