Click to See Complete Forum and Search --> : Returning Column Comments?


calliepeck
11-02-2008, 07:23 AM
Does anyone know a way to query column comments from PHP and return them (in an array, i suppose?) The research seems so far to say no, but I thought I'd give it a last ditch effort.

I'm working on a little CMS class that would run through a table and search its comments to note which kind of form field to create. I'm trying to auto-generate forms and form handling scripts from my tables without screwing too much with column names. Has anyone had experience with this kind of thing?

scragar
11-02-2008, 07:47 AM
$sql = "SHOW FULL COLUMNS FROM `{$tableName}`";
$rs = mysql_query($sql);

$fields = Array();// for storing info :P

while(FALSE !== ($row = mysql_fetch_assoc($rs)) ){
$fields[$row['Field']] = $row['Comment'];
}
var_dump($fields);