Just a quick question: Which of the following ways of executing UPDATE is the preferred method?
Pretty mundane stuff but any advice will be greatly appreciated.# clean sub not shown my $nick = clean(param('nick')); # Method 1 ( Use prepare ) -------------------------- $dbh = open_dbi(); my $sth = $dbh->prepare(qq{ UPDATE $table{'logins'} SET online='N' WHERE nick=? }); $sth->execute($nick) or bail_out("Cannot execute UPDATE"); # Close connection #Method 2 ( Use do() ) ---------------------- $dbh = open_dbi(); my $sql = qq{ UPDATE $table{'logins'} SET online='N' WHERE nick=$nick }); $dbh->do($sql) or bail_out("Cannot execute UPDATE"); # Close connection
20040115 Edit by BazB: Changed title from 'perl dbi question...'
In reply to DBI prepare() vs do() usage by kiat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |