I'm trying to grab the enum values from a column in a table using the DBI column_info method. According to the DBI docs I should be able to do this:
However, when I do this:
my $hash_ref = $sth->fetchall_hashref('COLUMN_NAME');
print Dumper $hash_ref;
I get this error:
By that message it looks like I can't specify a column, correct? If I use % as the column name it will work but I get every column in the table. I came up with this as a workaround for now:
->fetchall_hashref('COLUMN_NAME')->{item_uom}->{mysql_values};
I have two questions:
1) Is there an easier way to get the enum values for a column?
and more importantly:
2) (DB design related) Should I be going about this in a different way? With unit of measure being somewhat dynamic I'm thinking I might should have another table for unit of measure options.
Thanks,
Charlie
Quote:
$sth = $dbh->column_info( $catalog, $schema, $table, $column );However, when I do this:
Code:
my $sth = $dbh->column_info(undef, undef, 'prefix_item', 'item_uom'); my $hash_ref = $sth->fetchall_hashref('COLUMN_NAME');
print Dumper $hash_ref;
I get this error:
Quote:
DBD::mysql::db column_info failed: column_info doesn't support column selection at ...test.cgi line ##.By that message it looks like I can't specify a column, correct? If I use % as the column name it will work but I get every column in the table. I came up with this as a workaround for now:
Code:
my $fields = $dbh->column_info(undef, undef, 'prefix_item', '%') ->fetchall_hashref('COLUMN_NAME')->{item_uom}->{mysql_values};
I have two questions:
1) Is there an easier way to get the enum values for a column?
and more importantly:
2) (DB design related) Should I be going about this in a different way? With unit of measure being somewhat dynamic I'm thinking I might should have another table for unit of measure options.
Thanks,
Charlie