Last active
November 4, 2022 14:42
-
-
Save prezire/080fdd4ade10a22ab0f3 to your computer and use it in GitHub Desktop.
For NodeJS
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
var HaversineHelper = { | |
getQueryString: function | |
( | |
latitiude, | |
longitude, | |
keywords | |
){ | |
return "SELECT id, post_id, full_name, description, (6371 * acos(cos(radians($latitude)) * cos(radians(latitude)) * cos(radians(longitude) - radians(longitude)) + sin(radians(latitude)) * sin(radians(latitude)))) distance FROM wp_locations WHERE full_name LIKE '%$keywords%' OR description LIKE '%keywords%' GROUP BY full_name HAVING distance < $distance ORDER BY distance LIMIT 0, 20"; | |
} | |
}; | |
module.exports = HaversineHelper; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment