in reply to DBI prepare() vs do() usage
It depends. If it's a one-shot deal, I (personally) would prefer do() since it's more straightforward, and that's pretty much what it's for. If, however, you plan to do this in a loop, for many updates, so then you'd want to prepare() once, then execute() many times. But, in any case, you should still use placeholders in your do:
#Method 2 ( Use do() ) ---------------------- $dbh = open_dbi(); my $sql = qq{ UPDATE $table{'logins'} SET online='N' WHERE nick=? }); $dbh->do($sql, undef, $nick) or bail_out("Cannot execute UPDATE"); # Close connection
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: DBI prepare() vs do() usage
by kiat (Vicar) on Dec 21, 2003 at 14:22 UTC | |
by jeffa (Bishop) on Dec 21, 2003 at 14:54 UTC |