my @columns = map { substr($_,1) } keys %{$q{'-values'}};
Um, all that does is create a list of the columns with the first letter of the column name missing...
Anyhow, about specifying the columns in any order in the SQL query, would the following code always work correctly?
my $ph = join ', ', ('?') x values %{$q{'-values'}};
my $sth = $self->{$db_handle}->prepare(
"INSERT INTO $q{'-table'} (" .
join(',', keys %{$q{'-values'}}) .
") VALUES($ph)"
);
$sth->execute(values %{$q{'-values'}});
All I'm really asking is whether the order of keys %hash and values %hash are always the same in perspective to each other...
Update: lol, as soon as I finished posting this post, your update was there :) I understand now why you supplied the code you did. It was to get rid of the hyphens you thought were there :) |