Hey,

Basically trying to get 1 set of results returned, along with all column
names at the same time.

Is there an easier way to do it than this? Here's what I have:

(Note: MySQL database)

my $tablename = "tablename"; #get around taint warning
$sql = "LISTFIELDS $tablename";
$sth = $dbh->prepare($sql);
$sth->execute;
@generic = @{$sth->{NAME}};
@perm = @generic;
$sth->finish;

$sql = "Select * from tablename where idnr='$somenumber'";
$sth = $dbh->prepare($sql);
$sth->execute;
@generic = $sth->fetchrow;
@results = @generic;
$sth->finish;

$count = @perm;
$i = 0;
do {
print "$i - $perm[0] is $results[0]<br>";
$i++;
} until ($i >= $count);


Ignore the last part, it's just an example of what I'm trying to do with the
results. I know it's nasty, I do better code than that. ;-)

This works, but I'm not sure how well to trust it with it being two separate
statements.

Is there a better way? I've been working with DBI for quite a while, but
haven't had to deal with column names until now.

Thanks,
Joe
-- 
Now Playing: Joan Jett - Everyday People 
[From Album (1983)] (1:07/2:41)
Powered by XMMS and SuSE Linux 8.2 Pro


Reply via email to