jeffa is right on.
Working with hashes, both on the input side and select side is easy:
my $stmt = 'INSERT INTO some_table (' . join(',', keys %data_to_insert +) . ') VALUES (' . join(',', ('?') x keys %data_to_insert) . ')'; $dbh->do( $stmt, undef, values %data_to_insert);
and selecting it:
my $stmt = 'SELECT * FROM some_table WHERE entry_id = ?'; my $row = $dbh->selectrow_hashref($stmt, undef, $entry_id); my $full_name = $row->{first_name'} . ' ' . $row->{last_name'};
Be sure to see gmax's wonderful DBI Recipes.
In reply to Re: Store hash in mysql
by bradcathey
in thread Store hash in mysql
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |