php - Sort issue- Orderby non db column -
i have database zipcodes, latitude , longitude. other database have has cars zipcodes of location. have function return distance between user location (pulled ip address) , and cars location (based on zipcode, latitude , longitude). want order cars closest user. not sure best method.
i imagine orderby(distance asc), distance isn't in db , obtained on per user basis.
language: php, mysql framework: yii2
if function in mysql (e.g. stored function) can order function fine using say, order user_distance(user, distance) or similar.
if function within php code (not-mysql) need sort results after got query back. php has various functions this:
you want 1 of user-defined sort functions found here: http://php.net/manual/en/array.sorting.php
Comments
Post a Comment