in reply to Re: DBI determine primary key
in thread DBI determine primary key
It'd probably be more readable to use a selectall_hashref and (in the MySQL case) snagmy $keys_ref = $dbh->selectall_arrayref("SHOW KEYS FROM $table"); + foreach my $row ( @{$keys_ref} ) { print "Primary key: $row->[4]" if $row->[2] eq 'PRIMARY'; }
$row->{'Column_name'} if $row->{'Key_name'} eq 'PRIMARY'
Edited by Chady -- added code tags.
|
|---|