教义2 - 2位小数位在浮动? [英] Doctrine 2 - 2 decimal places on a float?
问题描述
注释:
/ **
* @ ORM\Column(type =float =2)
* /
protected $ curr_price;
我正在使用Symfony 2。
这个字段在MySQL数据库中变成了一个double,而不是float的2分精度。
我做错了什么?我尝试删除DB,重新插入等...
两个精度
和 scale
属性仅与 decimal
映射类型(链接)。我建议你使用 decimal
类型。
至于为什么它创建一个双字段而不是浮点数,不完全确定它可能与兼容所有支持的数据库有关。我看到没有提到 double
映射类型,所以我假设两者使用相同的类型。
Annotation:
/**
* @ORM\Column(type="float", scale="2")
*/
protected $curr_price;
I'm using it with Symfony 2.
And this field becomes a double in MySQL database instead of float with 2 point precision.
What am I doing wrong? I tried deleting the DB, reinserting etc...
Both precision
and scale
properties work only with the decimal
mapping type (link). I suggest you use the decimal
type.
As to why it's creating a double field instead of float, I'm not entirely sure. It probably has to do with being compatible with all supported databases. I see no mention of double
mapping type so I assume they use the same type for both.
这篇关于教义2 - 2位小数位在浮动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!