PDO::PARAM 用于十进制类型? [英] PDO::PARAM for type decimal?
本文介绍了PDO::PARAM 用于十进制类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 2 个数据库字段
I have 2 database fields
`decval` decimal(5,2)
`intval` int(3)
我有 2 个 pdo 查询来更新它们.更新 int 的那个工作正常
I have 2 pdo queries that update them. The one that updates the int works ok
$update_intval->bindParam(':intval', $intval, PDO::PARAM_INT);
但我无法更新十进制字段.我已经尝试了以下 3 种方法,但没有任何效果
but I can't update the decimal field. I've tried the 3 ways below, but nothing works
$update_decval->bindParam(':decval', $decval, PDO::PARAM_STR);
$update_decval->bindParam(':decval', $decval, PDO::PARAM_INT);
$update_decval->bindParam(':decval', $decval);
问题似乎出在数据库类型 decimal
上?decimal
类型的字段是否有PDO::PARAM
?如果没有,我可以使用什么作为解决方法?
It seems the problem is with the database type decimal
? Is there a PDO::PARAM
for a field of type decimal
? If not, what do I use as a workaround?
推荐答案
没有任何用于小数/浮点数的 PDO::PARAM
,你必须使用 PDO::PARAM_STR
.
There isn't any PDO::PARAM
for decimals / floats, you'll have to use PDO::PARAM_STR
.
这篇关于PDO::PARAM 用于十进制类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文