From 08ba06816e847a62edcef3aa430e0acf4c5ccdb3 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 12 Sep 2012 22:06:04 +0100 Subject: [PATCH 1/1] database editing etc. works --- mason/main | 5 +++++ mason/save | 3 +++ 2 files changed, 8 insertions(+) diff --git a/mason/main b/mason/main index 03a01d9..a9bc72e 100755 --- a/mason/main +++ b/mason/main @@ -54,8 +54,13 @@ $sth->execute(); <&| txtable, tx => $row &> % $sthi->execute($row->{'textid'}); +% my $anyused = 0; % while (my $rowi= $sthi->fetchrow_hashref()) { Used for:<% $rowi->{'emailaddr'} |h %> +% $anyused++; +% } +% if ($anyused) { +Not currently in use % }
diff --git a/mason/save b/mason/save
index cedd05b..c749084 100755
--- a/mason/save
+++ b/mason/save
@@ -48,12 +48,15 @@ $dinsertq->execute($textid, $desc, $subject, $text);
 my $tdeleteq = $dbh->prepare("DELETE FROM addresses WHERE textid = ?");
 $tdeleteq->execute($textid);
 
+my $odeleteq = $dbh->prepare("DELETE FROM addresses WHERE emailaddr = ?");
+
 my $tinsertq = $dbh->prepare("INSERT INTO addresses (emailaddr, textid)".
 			     " VALUES (?,?)");
 my $tlistq = $dbh->prepare("SELECT * FROM config");
 $tlistq->execute();
 while (my $row = $tlistq->fetchrow_hashref()) {
     if ($ARGS{"u_".hquote($row->{'emailaddr'})}) {
+	$odeleteq->execute($row->{'emailaddr'});
 	$tinsertq->execute($row->{'emailaddr'}, $textid);
     }
 }
-- 
2.30.2