summaryrefslogtreecommitdiff
path: root/bucky2/lib
diff options
context:
space:
mode:
authorJules Laplace <carbon@melanarchy.org>2013-12-23 17:56:45 -0600
committerJules Laplace <carbon@melanarchy.org>2013-12-23 17:56:45 -0600
commit6f8676aae207c3b631643a526890f813e973194c (patch)
treec5428dbdb8eff209cbb979c466969ba5317f8e99 /bucky2/lib
parentb8dd26303f26dd583ef79b42e17e89f8cb76bacc (diff)
bucky2 db update, script to fix bad file move
Diffstat (limited to 'bucky2/lib')
-rw-r--r--bucky2/lib/Bucky/DB.pm21
1 files changed, 21 insertions, 0 deletions
diff --git a/bucky2/lib/Bucky/DB.pm b/bucky2/lib/Bucky/DB.pm
index bca92b7..9690f40 100644
--- a/bucky2/lib/Bucky/DB.pm
+++ b/bucky2/lib/Bucky/DB.pm
@@ -39,6 +39,26 @@ sub insert
}
sub update
{
+ my ($self, $type, $opt) = @_;
+ my $criteria = $opt->{'criteria'};
+ my $record = $opt->{'record'};
+
+ $type = $DB_LOOKUP->{$type};
+ return unless $type && ref($record) eq "HASH" && scalar keys %$record;
+ my $key_values = [];
+ foreach my $key (keys %$record)
+ {
+ push @$key_values, $key . "=" . $self->quote($record->{$key});
+ }
+ my $key_value_string = join ",", @$key_values;
+ return unless length $key_value_string;
+
+ my $criteria_string = $self->criteria($criteria);
+ return unless length $criteria_string;
+
+ my $sql = "UPDATE $type SET $key_value_string WHERE $criteria_string";
+
+ $self->execute($sql);
}
sub select
{
@@ -103,6 +123,7 @@ sub execute
my ($self, $sql) = @_;
my $sth = $self->dbh->prepare($sql);
$sth->execute;
+
return $sth;
}
sub quote