您需要将自定义函数与 Doctrine2 一起用于地理坐标。
尝试使用此自定义DistanceFunction
:https ://gist.github.com/Koc/3016704
或者这个包:https ://github.com/craue/CraueGeoBundle
以下是 Doctrine 函数提供的所有列表:http: //docs.doctrine-project.org/en/latest/reference/dql-doctrine-query-language.html#dql-functions
IDENTITY(single_association_path_expression [, fieldMapping]) - Retrieve the foreign key column of association of the owning side
ABS(arithmetic_expression)
CONCAT(str1, str2)
CURRENT_DATE() - Return the current date
CURRENT_TIME() - Returns the current time
CURRENT_TIMESTAMP() - Returns a timestamp of the current date and time.
LENGTH(str) - Returns the length of the given string
LOCATE(needle, haystack [, offset]) - Locate the first occurrence of the substring in the string.
LOWER(str) - returns the string lowercased.
MOD(a, b) - Return a MOD b.
SIZE(collection) - Return the number of elements in the specified collection
SQRT(q) - Return the square-root of q.
SUBSTRING(str, start [, length]) - Return substring of given string.
TRIM([LEADING | TRAILING | BOTH] [‘trchar’ FROM] str) - Trim the string by the given trim char, defaults to whitespaces.
UPPER(str) - Return the upper-case of the given string.
DATE_ADD(date, days, unit) - Add the number of days to a given date. (Supported units are DAY, MONTH)
DATE_SUB(date, days, unit) - Substract the number of days from a given date. (Supported units are DAY, MONTH)
DATE_DIFF(date1, date2) - Calculate the difference in days between date1-date2.
acos, cos, radians
默认不支持(没有自定义扩展)。