I’m using Postgres and storing lat/long information in a table. Given input variables lat and lon, I can retrieve a distance-ordered list of locations using the earthdistance module and a query such as:
SELECT pub.id, pub.name,
earth_distance(ll_to_earth(lat, lon), ll_to_earth(pub.latitude, pub.longitude)) AS distance
FROM pubnames pub
ORDER BY distance ASC;
What’s the most Slim way of retreiving the same list?
I’m prototyping an API using tuupola’s slim-api-skeleton. It’s a cool project, but uses a number of tools that I’m unfamiliar with (and I assumed they were a part of Slim when I created this post). For example, Spot ORM is used to map calls to the database. Something like “SELECT * FROM todos;” is executed using: