From 9ec9729691f019be3214d1d20abec935ae58d58c Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 23 Dec 2013 18:22:26 -0600 Subject: update_by_id syntax, working script --- bucky2/lib/Bucky/DB.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'bucky2/lib/Bucky/DB.pm') diff --git a/bucky2/lib/Bucky/DB.pm b/bucky2/lib/Bucky/DB.pm index 9690f40..682e48e 100644 --- a/bucky2/lib/Bucky/DB.pm +++ b/bucky2/lib/Bucky/DB.pm @@ -56,10 +56,18 @@ sub update my $criteria_string = $self->criteria($criteria); return unless length $criteria_string; - my $sql = "UPDATE $type SET $key_value_string WHERE $criteria_string"; + my $sql = "UPDATE $type SET $key_value_string $criteria_string"; $self->execute($sql); } +sub update_by_id + { + my ($self, $type, $opt) = @_; + my $id = $opt->{'id'} + 0; + $opt->{'criteria'} = "id=$id"; + + $self->update($type, $opt) + } sub select { my ($self, $type, $criteria) = @_; -- cgit v1.2.3-70-g09d2