From f8d145c3a7da1e2f0d62d33a4998cb3e78b914be Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sun, 24 Jan 2016 16:18:29 -0800 Subject: [PATCH] Create find-supporter script. --- scripts/find-supporter.plx | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 scripts/find-supporter.plx diff --git a/scripts/find-supporter.plx b/scripts/find-supporter.plx new file mode 100755 index 0000000..70e3b18 --- /dev/null +++ b/scripts/find-supporter.plx @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use autodie qw(open close); +use DBI; +use Encode qw(encode decode); + +use Supporters; + +if (@ARGV < 2) { + print STDERR "usage: $0 \n"; + exit 1; +} + +my($SUPPORTERS_SQLITE_DB_FILE, $CRITERION, $SEARCH_PARAMETER, $VERBOSE) = @ARGV; +$VERBOSE = 0 if not defined $VERBOSE; + +my $dbh = DBI->connect("dbi:SQLite:dbname=$SUPPORTERS_SQLITE_DB_FILE", "", "", + { RaiseError => 1, sqlite_unicode => 1 }) + or die $DBI::errstr; + +my $sp = new Supporters($dbh, ['none']); + +my $found = 0; +my(@supporterIds) = $sp->findDonor({$CRITERION => $SEARCH_PARAMETER }); +foreach my $id (@supporterIds) { + print "Found: $id, ", $sp->getLedgerEntityId($id), "\n"; + $found = 1; +} +print "No entries found\n" unless $found; +############################################################################### +# +# Local variables: +# compile-command: "perl -c send-mass-email.plx" +# End: +