Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

RE: Re: Field names of database table from DBI

by jettero (Monsignor)
on Aug 01, 2000 at 16:08 UTC ( [id://25437]=note: print w/replies, xml ) Need Help??


in reply to Re: Field names of database table from DBI
in thread Field names of database table from DBI

I'm pretty sure LISTFIELDS doesn't work in my mysql. I've always used this:
my $s = $h->prepare("show fields from $table"); $s->execute; $s->bind_col(1, \$name); push @names, $name while($s->fetch);

Replies are listed 'Best First'.
RE: RE: Re: Field names of database table from DBI
by Anonymous Monk on Aug 02, 2000 at 02:01 UTC
    SHOW COLUMNS FROM $table should also work
    #!/usr/bin/perl # connect to db my $dbh = DBI->connect(bla..bla..bla); my $sql_q = "SHOW COLUMNS FROM $table"; my $sth = $dbh->prepare($sql_q); $sth->execute; while (@row = $sth->fetchrow_array){ print"Field Type Null Key Default Extra\n"; print"----------------------------------------------------\n"; print"$row[0] $row[1] $row[2] $row[3] $row[4] $row[5]\n"; }
      This is database dependant. It won't work for MS SQL through the DBD::ODBC driver, for instance.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://25437]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-23 22:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found