mysql 用特殊运算符(加法、减法等)准备语句?
这种情况会起作用吗:
$query = ' UPDATE users SET balance = (balance + ?) WHERE user = ? ';
$sth = $dbh->prepare($query);
$sth->execute(array($rechargeamount, $username));
基本上,一个准备好的金额声明,后跟一个加法运算符。或者准备好的声明也必须包括“余额”值?
非常感谢!
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?
many thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
会工作的。确保您准备好作为 int (取决于您使用的 sql 引擎)
Will work. Make sure you prepare out as an int (depends on which sql engine you're using)