Skip to content

Instantly share code, notes, and snippets.

@kovagoz
Created January 9, 2014 22:57
Show Gist options
  • Save kovagoz/8343702 to your computer and use it in GitHub Desktop.
Save kovagoz/8343702 to your computer and use it in GitHub Desktop.
Doctrine MongoDB geospatial query example
<?php
$city = DB::createQueryBuilder('Ni\City')
->field('coordinates')->geoNear(46.1643154116, 18.9664363861)
->spherical(true)
->distanceMultiplier(6378.137) // rad => km
->limit(1)
->getQuery()
->getSingleResult();
echo $city->name;
var_dump($city->distance);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment