php mongodb find distinct val返回多个参数

时间:2013-08-19 10:22:16

标签: php mongodb distinct

我的文件如下:

[_id] => MongoId Object (
    [$id] => ...
)
[homeId] => 39898
[sensor] => bopt
[date] => MongoDate Object (
    [sec] => 1376258370
    [usec] => 0
)
[val] => 5687

我要查询'date.sec','sensor','homeId'和'val'。 问题是,我希望'val'成为DISTINCT

$this->condition = array('homeId' => (int)$this->homeId, 'date' => array('$gte' => new MongoDate($this->fromDate), '$lt' => new MongoDate($this->toDate)), 'sensor' => $this->sensor);
$cursor = $this->collection->distinct('val',$this->condition);

我怎样才能让它不仅返回'val'而且返回所有字段?

谢谢!

0 个答案:

没有答案