injunjoel has asked for the wisdom of the Perl Monks concerning the following question:
The issue arises when checking the value of $update_success. The first method does not return a value consistently (at least not consistently enough for me to code with). Where as the latter method returns a value but does not allow for the flexibility of the first method, and the query must be recreated with each successive call.###idiosyncratic paranoid method wherein I prepare everything. my $sth = $dbh->prepare("UPDATE mytable SET value1=?, value2=? WHERE i +d=?") || die $dbh->errstr; my $update_success = $sth->execute($val1,$val2,$id) || die $sth->errst +r; ###non paranoid method cleaner as well. my $update_success = $dbh->do("UPDATE mytable SET value1='$val1', valu +e2='$val2' WHERE id=$id") || die $dbh->errstr;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Return values from $dbh->do vs. $sth->execute();
by mpeppler (Vicar) on Nov 24, 2003 at 22:59 UTC | |
by injunjoel (Priest) on Nov 24, 2003 at 23:46 UTC | |
by mpeppler (Vicar) on Nov 24, 2003 at 23:58 UTC | |
|
Re: Return values from $dbh->do vs. $sth->execute();
by BUU (Prior) on Nov 25, 2003 at 04:12 UTC |