Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 这个函数有什么问题,应该在mongo db中进行地理空间查询?_Php_Mongodb_Geospatial - Fatal编程技术网

Php 这个函数有什么问题,应该在mongo db中进行地理空间查询?

Php 这个函数有什么问题,应该在mongo db中进行地理空间查询?,php,mongodb,geospatial,Php,Mongodb,Geospatial,我有一个在mongodb-php中进行地理空间查询的函数。我不知道为什么,但它没有返回任何东西。(我有一个名为EVENTS的集合,里面有一个数组,有两个字段经度、纬度和用户位置坐标)。我想查询用户位置(1000米距离)附近的事件。你知道它有什么毛病吗 public function findEventsByUsersLocation($lng, $lat){ $c_events = $this->db->events; $c_events->find(array

我有一个在mongodb-php中进行地理空间查询的函数。我不知道为什么,但它没有返回任何东西。(我有一个名为EVENTS的集合,里面有一个数组,有两个字段经度、纬度和用户位置坐标)。我想查询用户位置(1000米距离)附近的事件。你知道它有什么毛病吗

public function findEventsByUsersLocation($lng, $lat){
    $c_events = $this->db->events;
    $c_events->find(array('lnglat'=> array('$near'=>array($lng, $lat),
                                    '$maxDistance' => 1000)));
}

我不得不把它放回原处。奥列格正在写作

public function findEventsByUsersLocation($lng, $lat){
$c_events = $this->db->events;
return $c_events->find(array('lnglat'=> array('$near'=>array($lng, $lat),
                                '$maxDistance' => 1000)));

}

也许,您应该在
$c_events->find()之前添加
return