[pm-h] Fwd: Fields names froma table
Fraser Baker
flbaker at sbcglobal.net
Fri Mar 12 05:32:28 PST 2010
Thanks. I ended up with something very similar to your suggestions.
Fraser
----- Original Message -----
From: Bart Hampshire
To: TX. Houston.pm located in Houston
Sent: Thursday, March 11, 2010 2:01 PM
Subject: [pm-h] Fwd: Fields names froma table
You might also try (you might have to change the query to actually return a row):
my $sth = $dbh->prepare("select * from myTable where 1=2");
$sth->execute;
my $rc = $sth->fetchrow_hashref;
foreach my $key (keys %{$rc}) {
print $key;
}
$sth->finish;
Sorry for any typos as I'm not using a proper keyboard.
Bart
Begin forwarded message:
From: Michael Dickens <cmdickens at gmail.com>
Date: March 11, 2010 13:43:17 CST
To: "Houston.pm located in Houston, TX." <houston at pm.org>
Subject: Re: [pm-h] Fields names froma table
Reply-To: "Houston.pm located in Houston, TX." <houston at pm.org>
Hi Fraser,
have you tried using a query 'DESC my_table' and then fetchrow_array something like:
my $sth = $dbh->prepare("DESC my_table");
$sth->execute();
my @fields = $sth->fetchrow_array;
$sth->finish();
Michael
On Thu, Mar 11, 2010 at 11:32 AM, Fraser Baker <flbaker at sbcglobal.net> wrote:
Hi:
OK, I finally have a question.
How do I get a list of field names from a mySQL table using DBI? I don't need the values.
I have put my time in, but can't get it to work.
Fraser
_______________________________________________
Houston mailing list
Houston at pm.org
http://mail.pm.org/mailman/listinfo/houston
Website: http://houston.pm.org/
--
easy as Perl
_______________________________________________
Houston mailing list
Houston at pm.org
http://mail.pm.org/mailman/listinfo/houston
Website: http://houston.pm.org/
------------------------------------------------------------------------------
_______________________________________________
Houston mailing list
Houston at pm.org
http://mail.pm.org/mailman/listinfo/houston
Website: http://houston.pm.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/mailman/private/houston/attachments/20100312/0fff1085/attachment.html>
More information about the Houston
mailing list