2016-05-01 16 views

回答

0

与shell一样,PHP驱动程序提供了.count方法,这正是您在此需要的,也是为了访问嵌入式文档中的“华氏”字段,您需要使用dot notation

$collection->count(
    array(
     "high.fahrenheit" => array("$gte" => 120), 
     "low.fahrenheit" => array("$lte" => -60) 
    ) 
) 

这相当于在外壳下面的查询:

db.collection.count({ 
    "high.fahrenheit": { "$gte": 120 }, 
    "low.fahrenheit": { "$lte": -60 } 
}) 
相关问题