Revert back to the old setRow that handles sparse updates, like the one used by Group.
This commit is contained in:
parent
e830e922c8
commit
ad88c37581
1 changed files with 20 additions and 16 deletions
|
|
@ -961,24 +961,28 @@ Use this ID to create a new row. Same as setting the key value to "new" except t
|
|||
=cut
|
||||
|
||||
sub setRow {
|
||||
my ($self, $table, $keyColumn, $data, $id) = @_;
|
||||
if ($data->{$keyColumn} eq "new" || $id) {
|
||||
$data->{$keyColumn} = $id || $self->session->id->generate();
|
||||
}
|
||||
my $dbh = $self->dbh;
|
||||
my @fields = ();
|
||||
my @data = ();
|
||||
my @placeholders = ();
|
||||
foreach my $key (keys %{$data}) {
|
||||
push(@fields, $dbh->quote_identifier($key));
|
||||
push(@placeholders, '?');
|
||||
push(@data,$data->{$key});
|
||||
}
|
||||
$self->write("replace into $table (" . join(",",@fields) . ") values (".join(",",@placeholders).")",\@data);
|
||||
return $data->{$keyColumn};
|
||||
my ($self, $table, $keyColumn, $data, $id) = @_;
|
||||
if ($data->{$keyColumn} eq "new" || $id) {
|
||||
$data->{$keyColumn} = $id || $self->session->id->generate();
|
||||
$self->write("replace into ".$self->dbh->quote_identifier($table)
|
||||
." (" . $self->dbh->quote_identifier($keyColumn) . ") values (?)",[$data->{$keyColumn}]);
|
||||
}
|
||||
my @fields = ();
|
||||
my @data = ();
|
||||
foreach my $key (keys %{$data}) {
|
||||
unless ($key eq $keyColumn) {
|
||||
push(@fields, $self->dbh->quote_identifier($key).'=?');
|
||||
push(@data,$data->{$key});
|
||||
}
|
||||
}
|
||||
if ($fields[0] ne "") {
|
||||
push(@data,$data->{$keyColumn});
|
||||
$self->write("update ".$self->dbh->quote_identifier($table)." set " . join(", ", @fields)
|
||||
. " where " . $self->dbh->quote_identifier($keyColumn) . "=?", \@data);
|
||||
}
|
||||
return $data->{$keyColumn};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 unconditionalRead ( sql [, placeholders ] )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue