开发者

mysql prepared statements with special operators (addition, subtraction etc.)?

Would this scenario work:

$query = ' UPDATE users SET balance = (balance + ?) WHERE user = ? ';

$sth = $dbh->prepare($query);

$sth->execute(array($rechargeamount, $username));

basically, a prepared statement for an amount followed by an addition operator. Or would prepared statement have to include the "balance" value as well?

开发者_JAVA百科many thanks!


Will work. Make sure you prepare out as an int (depends on which sql engine you're using)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜