Created
January 9, 2014 22:57
-
-
Save kovagoz/8343702 to your computer and use it in GitHub Desktop.
Doctrine MongoDB geospatial query example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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