get setRow to work with field names with non-word characters
This commit is contained in:
parent
84a6f71c9b
commit
0ec07bc967
1 changed files with 4 additions and 3 deletions
|
|
@ -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};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue