带有php的Mongodb可以';t使用where查询


Mongodb with php can't use where query

我一直在用php-mongo驱动程序v.1.6.3安装Mongodb v.2.6.7当我获取数据时,所有数据都正常工作,但如果我使用where查询,它会返回空数组给我。

<?php
$m = new MongoClient();
$db = $m->selectDB('test');
$collection = new MongoCollection($db, 'phpmanual');
// search for documents where 5 < x < 20
$rangeQuery = array('x' => array( '$gt' => 5, '$lt' => 20 ));
$cursor = $collection->find($rangeQuery);
foreach ($cursor as $doc) {
    var_dump($doc);
}