Propel icon indicating copy to clipboard operation
Propel copied to clipboard

Float / decimal / double values converted in comma-separated ones (instead of point-separated ones)

Open elegos opened this issue 10 years ago • 1 comments

I've noticed that depending on the locale, these values are converted from float (PHP) to a string (may be a simple cast or whatever) relying on the default PHP behaviour. This means that if the current locale translates the decimal separator in a comma instead of a dot, this will translate in some troubles database-side (value = "1,23" instead of "1.23" means, at least in MySQL, "1.00").

The easiest way is to use sprintf with %F as formatting string, so that the locale is being ignored.

elegos avatar May 06 '15 12:05 elegos

I've done a workaround using setlocale(LC_NUMERIC, 'en_US') - but as previously written, it's a workaround. In my particular case it's not a problem, but some software may need to format decimals just the way the locale is set.

elegos avatar May 07 '15 06:05 elegos