Skip to content

Instantly share code, notes, and snippets.

Created May 14, 2013 14:28
Show Gist options
  • Save anonymous/5576377 to your computer and use it in GitHub Desktop.
Save anonymous/5576377 to your computer and use it in GitHub Desktop.
$idResults = $this->nativeSql->fetchAll(
"SELECT *, ((ACOS(SIN($lat * PI() / 180) * SIN(latitude * PI() / 180) + COS($lat * PI() / 180) * COS(latitude * PI() / 180) * COS(($lng - longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance
FROM school
HAVING distance <= $radiusInMiles"
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment