开发者

PDO returns floats with comma as decimal separator

Apparently PDO uses the php LC_NUMERIC category to format the output of floats according to the current locale in the resultse开发者_如何转开发ts.

This is a huge P.I.T.A. since i actually need the LC_NUMERIC to format my numbers but the results coming from the database should at all times be using the dot as decimal separator, else my calculations will be off.

Anyone has an idea if it's possible to configure PDO so it won't be using the php locale to format floats in query results.

Another option is a lot of locale juggling which i would rather not do, unless it's an absolute last measure.


Try PDO::setAttribute

PDO::ATTR_STRINGIFY_FETCHES: Convert numeric values to strings when fetching. Requires bool.

will be false in this case


It appears to be a bug in PHP 5.1.4, we've checked release notes and buglogs on php.net along with a technician from our hosting provider and couldn't find anything related to this behaviour, then we upgraded to a vps using php 5.2.1 and the problem disappeared.

It's not confirmed but it appears to be a bug related the the specific php version or mysqllib we were using.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜