2015-03-03 93 views
0

我已经安装Mongodb v.2.6.7与php mongo驱动程序v.1.6.3 当我得到数据所有它正常工作,但如果我使用where查询它返回空数组回到我的身边。Mongodb与php不能用在哪里查询

+0

哪里码? – 2015-03-03 08:32:57

+0

感谢Neil Lunn,现在我的问题已修复,但现在它有其他错误(1)返回结果数组空,但是当我使用限制(2)返回结果对我来说是正确的我不知道为什么?下面是我的代码使用: $ resutl = $ this-> mongo_db-> limit(1) - > get('UserProfile'); – 2015-03-05 07:28:09

回答

0
<?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); 
} 

source