Doctrine can be adapted to many different database vendors such as MySQL, PostgreSQL, and others. To achieve this and still be able to take advantage of the specifics of each underlying platform, Doctrine is designed in such a way that it is easy to define your own custom SQL functions.
We will take advantage of this for our geolocation. In the first chapter, we decided that the home page would only display events within 25 kilometers (which roughly translates to 0.3 in terms of latitude and longitude). To do so, we defined a box of coordinates around a given point and then used it in the SQL code.
However, an actual distance between two points (in a Cartesian plan) is calculated by the following formula:
The preceding formula ...