Doctrine ODM saving big number Doctrine ODM saving big number symfony symfony

Doctrine ODM saving big number


Last things first: The value is being displayed as the max-int value because PHP is seeing it as numeric. You can see more about this process here.

The mongodb extension itself does support 64-bit integers on 32-bit systems using MongoInt64, but the Doctrine ODM doesn't handle 32- or 64-bit integers differently when hydrating back from MongoDB, so you'll never see that 64-bit value come back as a MongoInt64 class, even if PHP could support it -- which it can't :)

SO, I'd say your options are either force the value to a string (echo (String) $number;), or try and troubleshoot why you are getting an error attempting to save the value as a float. There are precision issues with floats in php that may make it untenable to store the number that way regardless.

Hope this helps!