PDO :: PARAM类型小数? [英] PDO::PARAM for type decimal?

查看:162
本文介绍了PDO :: PARAM类型小数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个数据库字段

`decval` decimal(5,2)
`intval` int(3)

我有2个pdo查询来更新它们。更新int的工作原理ok

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆