hok_si_la has asked for the wisdom of the Perl Monks concerning the following question:
Though I am having issues attempting to handle multiple selects. See the code below for a failed example.use strict; use CGI; my ($cgi, $key, %IN); $cgi = new CGI; %IN = $cgi->Vars; #%IN = (param1 => value1, param2 => value2 , etc..);
Below is an example of one of my insert routines from my other scripts.if (defined $IN{location}) { $where .= "AND (location = '$IN{location}[0]'"; for my $i (@{$IN{location}}) { $where .= "$i" }; $where = "$where)"; }
delete $IN{somekey}; delete $IN{somekey1}; delete $IN{somekey2}; delete $IN{somekey3}; $IN{somekey4} = "someval"; foreach $key (keys %IN) { $keys[$i] = $key; $value = $IN{$key}; $value = $dbh->quote($value); #removes quotes from the values $values[$i] = $value; $i++; } my $key_string = join(',',@keys); #joins array elements, and status a +nd adds a comma my $value_string = join(',',@values"); #joins array values, and stat +us, and adds a comma $sql = "$function $tablename ($key_string) values ($value_string)"; $sth = $dbh->prepare($sql); $sth->execute();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: CGI.pm OO vs. FO
by kutsu (Priest) on Sep 09, 2005 at 20:41 UTC | |
Re: CGI.pm OO vs. FO
by CountZero (Bishop) on Sep 10, 2005 at 20:21 UTC |