MongoDB on Wamp x64 (win x64) = mongo.native_long error

I have a big problem with my development environment.

Context:
My computer: Win 8.1 x64
My installation of WampServer: x64
My MongoDB installs: x64 from http://www.mongodb.org/downloads

I installed the php extension from http://pecl.php.net/package/mongo .

My problem is that our production server stores 64 INT bits in the database.

When I try to access this data in my development environment, I have:

MongoCursorException

Cannot initially represent long 1108547148863410176 on this platform

I found on the Internet that the mongoDB parameter, called "mongo.native_long = 1", is needed to use 64-bit INT on a 64-bit architecture.
But when I try to add this parameter to my "php.ini" file, the server does not start and does not give me an error, for example:

[November 19, 2014 18:25:52 UTC] PHP Fatal error: starting PHP: to prevent data corruption, you are not allowed to enable the mongo.native_long parameter on 32-bit platforms in Unknown on line 0

Is my 32 bit mongoDB extension DLL or am I missing something?

+5
source share
3 answers

For me, the only thing that worked:

ini_set('mongo.long_as_object', 1); 

Hope this saves you some time. This is one of those stupid things that make you think: "Why the hell did I become a programmer?"

EDIT: driver from http://pecl.php.net/package/mongo helped me. I downloaded the latest driver. Test your version with the phpinfo () command. For instance. for me, on 64-bit Win7 this is:

 PHP Version 5.5.12 PHP Extension Build: API20121212,TS,VC11 

Pay attention to the line "TS, VC11". This means that Thread Thread, but your version may be unsafe (NTS).

So, I downloaded 64bit, TS for PHP 5.5. I ran into this problem for a long time, and finally, the correct driver solved this problem.

+5
source

When using the 32-bit apache console (for example, wampp or xampp) u, add the following to the php.ini file:

 mongo.long_as_object= 1 

The above line should convert all long objects to an object, so an exception will not occur.

Hope this helps all 32-bit users who have this issue.

+2
source

I had the same issue with WAMP x64 on Windows X64. My fix was to upgrade the Mongo library to version 1.6.14

0
source

Source: https://habr.com/ru/post/1207242/


All Articles