I've a big problem with my development environment.
Context :
My computer : Win 8.1 x64
My WampServer install : x64
My MongoDB install : x64 from http://www.mongodb.org/downloads
I've installed the php extension from http://pecl.php.net/package/mongo.
My problem is that our production server store some 64 bits INT into the database.
When I try, in my development environment, to access to this data, I've got:
MongoCursorException
Cannot natively represent the long 1108547148863410176 on this platform
I found on internet that a parameter of mongoDB called "mongo.native_long = 1" is needed to use 64 bits INT on 64 bits architecture.
But when I try to add this param in my "php.ini" file, the server don't start and give me an error like :
[19-Nov-2014 18:25:52 UTC] PHP Fatal error: PHP Startup: To prevent data corruption, you are not allowed to turn on the mongo.native_long setting on 32-bit platforms in Unknown on line 0
Does my mongoDB extension DLL is build on 32 Bit or I missed something to do ?
For me the only thing that worked was:
ini_set('mongo.long_as_object', 1);
Hope it saves someone's time. It's one of those stupid things that make you wonder: "Why the hell did I become a programmer?"
EDIT: getting proper driver from http://pecl.php.net/package/mongo helped me. I've downloaded latest driver. Check your version using phpinfo() command. E.g. for me, on 64-bit Win7 it's:
PHP Version 5.5.12
PHP Extension Build: API20121212,TS,VC11
Notice the "TS,VC11" string. It means it's Thread Safe, but your version may not be thread safe (NTS).
So I downloaded 64bit, TS for PHP 5.5. I was dealing with this problem long time and finally, proper driver solved this issue.
When using a 32 bit apache console(like wampp or xampp) u should add the following to your php.ini file:
mongo.long_as_object= 1
The above line should convert all longs to object, this way the exception won't occur.
Hope this helps all the 32 bit users that have this problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With