List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:September 1 1999 9:34pm
Subject:Re: How do I...
View as plain text  
At 2:11 PM -0500 9/1/99, Ronald Beck wrote:
>Thank you everyone for the recommendations I received.  However, none of
>them were really what I was looking for.
>I found the answer by reviewing the programs in the mysqladm, a web
>based MySQL Database Administration package that I downloaded from
>somewhere.  In it, I found the following snippet of code...
>    $cursor=$dbh->prepare("describe $table") ||
>        cgidie("Describe failed: describe $table");
>    $cursor->execute;
>    @fields = ();
>    @fielddefaults = ();
>    while (@fielddesc = $cursor->fetchrow)
>    {
>      push @fields, $fielddesc[0];
>      push @fielddefaults, $fielddesc[4];
>    }
>Note that @fields contains the column names and apparently
>@fielddefaults contains the field descriptions, which I didn't need.
>Once I had this information, it was a trivial matter to translate the
>field name to a variable and equate it with the value I pulled from the
>table with a SELECT... statement.

If all you want is the names of the columns for your result set, do this
after your execute:

@names = @{$sth->{NAME}};

Paul DuBois, paul@stripped
How do I...Ronald Beck30 Aug
  • Re: How do I...Ronald Beck1 Sep
    • Re: How do I...Paul DuBois2 Sep
Re: How do I...ef30 Aug