The info returned is not very useful. Try this instead
$sth->prepare("SHOW FIELDS from $table");
$sth->execute;
my %type;
while(@row = $sth->fetchrow_array) {
$type{$row[0]} = $row[1];
}
$sth->finish;
foreach $key(%type) {
print "Field Name: $key Type: $type{$key}\n";
}
This gives you a hash of fieldname:type pairs keyed on field name.
(though some field types will include the length, i.e. char(20) but a
good regular expression will take care of that ;-)
> Qiang Tan writes:
> > > Could somebody tell me how to get the fields' type through DBI:DBD of
> Perl?
> > > I tried one, but it does not work as stated in doc:
> Just fix:
>
> $types = $sth->{types};
>
> to
>
> $types = $sth->{type};
Take care of your shoes...
Jay
fty@stripped