【问题标题】:AggregateCursor issue with MongoDB 3.6MongoDB 3.6 的 AggregateCursor 问题
【发布时间】:2018-05-14 04:05:50
【问题描述】:

我已将我的 MongoDB 更新到 3.6 版本。我在 CentOS 7 和 PHP 5.5.38 上使用 PHP MongoClient。 如果我运行MongoDB库的aggregateCursor方法,通过http://php.net/manual/en/mongocollection.aggregatecursor.php报告的第一个例子,我得到如下错误信息:

PHP Fatal error:  Uncaught exception 'MongoCursorException' with message '95.110.150.99:27017: the command cursor did not return a correctly structured response' 

您对这种行为有任何想法吗?

【问题讨论】:

    标签: php mongodb aggregate-functions


    【解决方案1】:

    问题出在 Mongo 返回的 cursor id 中:

     ["id"]=>
        float(6.43105103109E+18)
    

    要构建 MongoCommandCursor 对象,id 应为 MongoInt64

    ["id"]=>
        object(MongoInt64)#5 (1) {
          ["value"]=>
          string(12) "392143983421"
        }
    

    可以通过设置来完成:

    ini_set('mongo.native_long', false);
    ini_set('mongo.long_as_object', true);
    

    该问题在以下位置进行了详细描述: https://derickrethans.nl/64bit-ints-in-mongodb.html

    【讨论】:

      猜你喜欢
      • 2018-06-06
      • 2011-01-15
      • 2019-04-19
      • 2018-04-13
      • 2018-08-18
      • 1970-01-01
      • 2018-08-15
      • 1970-01-01
      • 2018-06-15
      相关资源
      最近更新 更多