开发者

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

开发者 https://www.devze.com 2023-03-30 14:42 出处:网络
Would this scenario work: $query = \' UPDATE users SET balance = (balance + ?) WHERE user = ? \'; $sth = $dbh->prepare($query);

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

精彩评论

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