Hallo Sebastian --
> -----Ursprüngliche Nachricht-----
> Von: Sebastian Reinhardt [mailto:snr@stripped]
> Gesendet: Donnerstag, 7. Mai 2009 15:26
> To query an MYSQL- database, I have written a short CGI/Perl-
> Script. It is working well, except the naming of the result
> table! I try to fetch the column names from my database, to
> use it for the result table's head. I get the names, no
> problem so far, but these names are not in same order, as
> stored in the database!
>
> To fetch the names I use following code:
>
> --------------snip------------------
> my $sth = $dbh->column_info(undef,$d_base,$d_table,'%');
> my $col_info = $sth->fetchall_arrayref();
> $sth->finish();
> my $i = 0;
> foreach my $info(@$col_info)
> {
> $kat_info[$i]=@$info[3];
> $i++;
> }
> --------------snip------------------
Es ist einfacher ohne column_info() und funktioniert dann nicht nur für Tabellen,
sondern für beliebige SELECts:
----------------------
my $sth = $dbh->prepare(qq(select * from some_table were foo='bla')) or die "Yukk";
$sth->execute();
@kat_info = @{ $sth->{NAME_lc} };
# ... mach was mit @kat_info...
while (my $aryref = $sth->fetchrow_arrayref()) { ... }
----------------------
\Gisbert