in reply to DBI Insert not working
This does not directly relate to your issue. However, whenever I have a query like that, I often prefer to build the sql statement instead of having a chain of placeholders that might or might not be balanced with the correct field.
To ensure better readability and quality assurance, I simply create an intermediate data structure that is transformed into the fields and values like so:
my @pairs = ( name => $name, country => $country, language => $language, union => $union, title => $title, email => $email, cellphone => $cellphone, landlinephone => $landlinephone, facebook => $facebook, skype => $skype, twitter => $twitter, gender => $gender, age => $age, needshelp => $needshelp, ); my @fields = do {my $b = 0; grep {$b ^= 1} @pairs}; my @values = do {my $b = 1; grep {$b ^= 1} @pairs}; $sth = $dbh->prepare('INSERT INTO istanbul2011 SET ' . join ',', map { +"$_=?"} @fields)); $sth->execute(@values) or die $dbh->errstr
|
---|