From 0ec07bc9675539b9c1a24c9262581c593cb7b5a3 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 4 Nov 2008 22:46:44 +0000 Subject: [PATCH] get setRow to work with field names with non-word characters --- lib/WebGUI/SQL.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm index 46c5432f5..6238f0d17 100644 --- a/lib/WebGUI/SQL.pm +++ b/lib/WebGUI/SQL.pm @@ -925,19 +925,20 @@ sub setRow { my ($self, $table, $keyColumn, $data, $id) = @_; if ($data->{$keyColumn} eq "new" || $id) { $data->{$keyColumn} = $id || $self->session->id->generate(); - $self->write("replace into $table ($keyColumn) values (?)",[$data->{$keyColumn}]); + $self->write("replace into $table (" . $self->dbh->quote_identifier($keyColumn) . ") values (?)",[$data->{$keyColumn}]); } my @fields = (); my @data = (); foreach my $key (keys %{$data}) { unless ($key eq $keyColumn) { - push(@fields, $key.'=?'); + push(@fields, $self->dbh->quote_identifier($key).'=?'); push(@data,$data->{$key}); } } if ($fields[0] ne "") { push(@data,$data->{$keyColumn}); - $self->write("update $table set ".join(", ", @fields)." where ".$keyColumn."=?",\@data); + $self->write("update $table set " . join(", ", @fields) + . " where " . $self->dbh->quote_identifier($keyColumn) . "=?", \@data); } return $data->{$keyColumn}; }