AW: MySQL column_info() output order

Hallo Sebastian --

> -----Ursprüngliche Nachricht-----
> Von: Sebastian Reinhardt [mailto:snr [at] lmv-hartmannsdorf.de]
> 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 =3D $dbh->column_info(undef,$d_base,$d_table,'%');
> my $col_info =3D $sth->fetchall_arrayref();
> $sth->finish();
> my $i =3D 0;
> foreach my $info( [at] $col_info)
> {
> $kat_info[$i]=3D [at] $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 =3D $dbh->prepare(qq(select * from some_table were foo=3D'bla')) =
or die "Yukk";
$sth->execute();
[at] kat_info =3D [at] { $sth->{NAME_lc} };
# ... mach was mit [at] kat_info...
while (my $aryref =3D $sth->fetchrow_arrayref()) { ... }
----------------------

\Gisbert

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=3Dgcdmp-msql-mysql-modules [at] m.gmane.org
Gisbert.Selke [ Do, 07 Mai 2009 17:08 ] [ ID #2000446 ]

Re: AW: MySQL column_info() output order

Selke, Gisbert W. schrieb:
> Hallo Sebastian --
>
>
>> -----Ursprüngliche Nachricht-----
>> Von: Sebastian Reinhardt [mailto:snr [at] lmv-hartmannsdorf.de]
>> 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( [at] $col_info)
>> {
>> $kat_info[$i]= [at] $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();
> [at] kat_info = [at] { $sth->{NAME_lc} };
> # ... mach was mit [at] kat_info...
> while (my $aryref = $sth->fetchrow_arrayref()) { ... }
> ----------------------
>
> \Gisbert
>
>
Thanks!

Works great!

--

Sebastian Reinhardt



--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules [at] m .gmane.org
Sebastian Reinhardt [ Do, 07 Mai 2009 21:58 ] [ ID #2000447 ]
Datenbanken » gmane.comp.db.mysql.perl » AW: MySQL column_info() output order

Vorheriges Thema: Unexplained "out of memory"
Nächstes Thema: MySQL column_info() output order