使用PHP查询两个MongoDB集合,第一个返回正确的结果,但第二个为空

使用PHP查询两个MongoDB集合,第一个返回正确的结果,但第二个为空,php,mongodb,Php,Mongodb,我从PHP运行了两个MongoDB查询,一个查询第一个集合(名为“products”),第二个查询另一个集合(名为stats) 两个集合的一些数据: { "_id" : "20711122", "labels_hierarchy" : [ "en:pgi" ], "languages_hierarchy" : [ "en:french" ], "labels_prev_hierarchy" : [ "en:pgi" ], "languages" : { "e

我从PHP运行了两个MongoDB查询,一个查询第一个集合(名为“products”),第二个查询另一个集合(名为stats)

两个集合的一些数据:

{
"_id" : "20711122",
"labels_hierarchy" : [ 
    "en:pgi"
],
"languages_hierarchy" : [ 
    "en:french"
],
"labels_prev_hierarchy" : [ 
    "en:pgi"
],
"languages" : {
    "en:french" : 5
},
"countries_tags" : [ 
    "en:france"
],
"purchase_places_debug_tags" : [],
"photographers_tags" : [ 
    "tacite"
]
}
<pre><code>Interrogation de la collection : stats
Avec le filtre :
{"id":"7613035010550"}
<pre><code>Interrogation de la collection : products
Avec le filtre :
{"id":"7613035010550"}
Results :
{"ean":"7613035010550","title":"Eau Min\u00e9rale Naturelle","image":"https:\/\/static.openfoodfacts.org\/images\/products\/761\/303\/501\/0550\/front_fr.11.400.jpg","brands":"Vittel","categories":["Boissons","Eaux","Eaux min\u00e9rales","Eaux min\u00e9rales naturelles","Boissons non sucr\u00e9es"],"quantity":"1.5 l."}
其他收藏:

{
"_id" : "7613035010550",
"purchases" : [ 
    {
        "date" : ISODate("2017-04-15T14:15:00.000Z"),
        "coords" : {
            "lon" : 43.729604,
            "lat" : 1.416017
        },
        "metar" : {},
        "quantity" : 1,
        "price" : 2.31
    }, 
    {
        "date" : ISODate("2017-05-02T16:23:00.000Z"),
        "coords" : {
            "lon" : 43.722862,
            "lat" : 1.415837
        },
        "metar" : {},
        "quantity" : 6,
        "price" : 12
    }, 
    {
        "date" : ISODate("2017-05-02T18:32:00.000Z"),
        "coords" : {
            "lon" : 46.307353,
            "lat" : 3.28937
        },
        "metar" : {},
        "quantity" : 2,
        "price" : 5
    }
],
"rates" : [ 
    {
        "value" : 5
    }, 
    {
        "value" : 4
    }, 
    {
        "value" : 5
    }, 
    {
        "value" : 2
    }
]
}
正如您所看到的,集合是不同的,但是“\u id”键

当我对第一个集合(产品)运行查询时,一切正常,但第二个具有相同“\u key”的集合返回空结果,下面是两个查询的跟踪(使用MongoDB::Driver的executeQuery()进行):

正如你所看到的,只有第一个查询返回结果,而不是第二个

你知道这种奇怪的行为吗

Thx 4帮助


JL

我只是愚蠢或疲倦。。。 第二个查询是用“id”键执行的,但不是“\u id”键。。。所以,总是返回空结果

再喝4杯咖啡,然后

JL