PHP MongoDB驱动程序命令 - 未捕获的MongoDB \ Driver \ Exception \ RuntimeException:exception:未知的组运算符

时间:2017-09-19 21:44:32

标签: php mongodb

我在php7中有以下php mongo代码并且它失败并出现以下错误PHP致命错误:未捕获MongoDB \ Driver \ Exception \ RuntimeException:异常:未知组操作符'token'。我不确定是什么问题。堆栈跟踪在executeCommand上有它。知道这是什么问题吗?

$mongoClient = new MongoDB\Driver\Manager('mongodb://'.$mongo_server_address, $mongo_options);
$cmd = new MongoDB\Driver\Command(
    [
        'aggregate' => 'mycollection',
        'pipeline' => [
            ['$group' => [
                'key' => ["token" => 1],
                'reduce' => new \MongoDB\BSON\Javascript("function( curr, result ) { result.count++; }"),
                'cond' => [
                    'token' => ['$ne' => NULL],
                    'token' => ['$exists' => true, '$not' => ['$size' => 0]],
                    'createdAt' => ['$gte' => new MongoDB\BSON\UTCDateTime(strtotime(date('Y-m-d', strtotime('-1 days')) . ' 00:00:00')), '$lte' => new MongoDB\BSON\UTCDateTime(strtotime(date('Y-m-d') . ' 00:00:00'))]
                ],
                'initial' => ["count" => 0]
            ]]
        ],
        'cursor' => new stdClass()
    ]
 );
 $rows = $mongoClient->executeCommand($mongo_table_name, $cmd);

0 个答案:

没有答案
相关问题