in reply to prepared statement
my $address_exists_sth; sub address_exists { my ($address) = @_; $address_exists_sth ||= $dbh->prepare(' SELECT * FROM emails WHERE `email`=? ); $address_exists_sth->execute($address); my $rec = $address_exists_sth->fetch(); $address_exists_sth->finish(); return $rec && 1; } for my $address (@addresses) { if (address_exists($address)) { ... } }
Update: DBI can already do some of the work for us:
my $address_exists_sth; sub address_exists { my ($address) = @_; $address_exists_sth ||= $dbh->prepare(' SELECT * FROM emails WHERE `email`=? ); return $dbh->selectrow_arrayref($address_exists_sth) && 1; } for my $address (@addresses) { if (address_exists($address)) { ... } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: prepared statement
by james2vegas (Chaplain) on Aug 18, 2010 at 17:27 UTC | |
by saintex (Scribe) on Aug 18, 2010 at 19:30 UTC | |
by ikegami (Patriarch) on Aug 18, 2010 at 20:23 UTC | |
by james2vegas (Chaplain) on Aug 18, 2010 at 20:03 UTC | |
by saintex (Scribe) on Aug 19, 2010 at 11:11 UTC | |
by Tux (Canon) on Aug 19, 2010 at 14:00 UTC |