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?
Thanks!
Hello @mlucas,
You can use any database and any ORM you wish with Slim. So the “Slim way” would be which ever way you prefer.
Haha, I’m glad to hear it @tflight.
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:
$todos = $this->spot->mapper("App\Todo")
->all()
->order(["updated_at" => "DESC"]);
It looks handy, but it wasn’t clear how to order by computed fields. Looks like I’ll be looking into Spot ORM a bit now. Thanks for the help, Tim.
Ahh, I understand now. You’ve figured it out now that, no, Spot ORM isn’t part of Slim.