vendredi 1 février 2019

Why in laravel 5 / mysql 5 saving float value is rounded?

In my laravel 5.7 / mysql 5.7.25-0ubuntu0 app using eloquent I save float value (money), but value is rounded to int, so for value '12346301.67' I trace sql as :

   UPDATE `storage_spaces` set `updated_at` = '2019-02-01 10:31:41', `selling_range` = '12346301.67' 
    WHERE `id` = '1377' 

But in db I see value as “12346302.0000000”

Field defined as :

CREATE TABLE `storage_spaces` (
...
    `selling_range` FLOAT(17,7) NULL DEFAULT NULL,
...

What is wrong and how to fix it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire