PHP MySQL: Read out Comments from Table-Fields
Since Version 4.1 (or 5?) of MySQL you can comment each field of a table. Here is an example how to get these field-comments in PHP:
// Name of Table
$myTab = 'myTable';
// Resultarray (Fieldname => Comment)
$fieldComments = array();
// Get the Values
$tabFields = mysql_query('SHOW FULL COLUMNS
FROM `'.$myTab.'`');
while ($fieldAtts = mysql_fetch_assoc($tabFields)){
if (! empty($fieldAtts['Comment'])){
$fieldComments[$fieldAtts['Field']]
= $fieldAtts['Comment'];
}
}
// Example: Output to Browser
echo '<pre>'.print_r ($fieldComments, true).'</pre>';
techomatic - 2009-02-16 22:33
