0

I have a data structure which contains an object with fields with numerical names, e.g.

{1 : {views:42, impressions:999}, 2 : {...} ...}

This is not an 'array', just an identifiers. When I request those records via PHP Mongo extension 1.4.4 (both mongo 2.4.7 and web server are running on Win7) I receive those keys as expected, i.e.

2
    impressions    9
    views          0
3
    impressions    9
    views          9
1
    impressions    50
    views          50

But when this code runs in staging environment (LAMP, where we have mongo driver 1.6.0-dev, mongodb itself is 2.4.2) I receive them this weird way:

NumberLong(2)
    impressions    9
    views          0
NumberLong(3)
    impressions    9
    views          9
NumberLong(1)
    impressions    50
    views          50

where 'NumberLong(X)' is plain string, coming right from my cursor. It's not a big deal to fix this and replace numerical names with string ones, but I'm wondering what driver (or DB) behaves wrong and why.

Both servers have 'mongo.native_long' enabled.

1 Answer 1

2

It behaves like this because of how it is setup: http://www.php.net/manual/en/mongo.configuration.php

The setting you are looking for is: http://www.php.net/manual/en/mongo.configuration.php#ini.mongo.native-long

Sign up to request clarification or add additional context in comments.

5 Comments

Updated the question. Both servers have 'mongo.native_long' enabled.
@EugeneM Seems I didn't read quite close enough, though 1.6? I don't think there is a 1.6? github.com/mongodb/mongo-php-driver/releases
Yes, actually it's 1.6.0-dev. Haven't noticed this before, this might be an issue.
@EugeneM yeah downgrade to stable, though it might still happen there, but I will carry on if it still does
The default value for this changed in 1.5.0 - and is forced on 32bits builds. See the updated changelog on the linked page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.