diff options
-rwxr-xr-x | mat | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -16,7 +16,7 @@ tie my %Config, "Config::Simple", '/etc/mat.conf'; #use Data::Dumper; -my $db = DBI->connect("dbi:SQLite:recipe.db", "", "", {RaiseError => 1, +my $db = DBI->connect($Config{'database'}, "", "", {RaiseError => 1, AutoCommit => 1}); my @recipes; @@ -469,7 +469,7 @@ sub cmd_help() { print "shoppinglist <days_to_shop_for>\n"; print "queueshow\n"; print "queueadd <recipe_id> <servings>\n"; - print "queuerm (Yet to be implemented)\n"; + print "queuerm <queue_id>\n"; print "queuemv (Yet to be implemented)\n"; } @@ -667,7 +667,19 @@ sub cmd_queueshow { } sub cmd_queuerm { - print "Yet to be implemented!\n"; + my ( $queue_id ) = @_; + + my $sql = "DELETE FROM queue WHERE id=$queue_id;"; + my $sth = $db->prepare($sql); + my $rv = $sth->execute; + + my $id = $queue_id; + do { + my $next = $id + 1; + $sql = "UPDATE queue SET id=$id WHERE id=$next;"; + + $id++; + } while($db->do($sql) == 1); } sub cmd_queuemv { |