0
查詢我有一個表像這個 -Laravel查詢生成器 - 用特殊的數據類型
所以,我有user_location
一個特殊的數據類型(POINT
)。
的RAW選擇查詢就像是這個 -
SELECT
id,
full_name,
website,
X(user_location) AS "latitude",
Y(user_location) AS "longitude",
(
GLength(
LineStringFromWKB(
LineString(
user_location,
GeomFromText('POINT(51.5177 -0.0968)')
)
)
)
)
AS distance
FROM users
ORDER BY distance ASC;
,結果是 -
我想在Laravel與查詢生成器使用它,這樣(51.5177
-0.0968
)本2分可以來自用戶輸入。
我已經是 -
DB::table('users')
->select(
id,
full_name,
website,
DB::raw('X(user_location) AS "latitude"'),
DB::raw('Y(user_location) AS "longitude"'),
DB::raw('(
GLength(
LineStringFromWKB(
LineString(
user_location,
GeomFromText('POINT(51.5177 -0.0968)')
)
)
)
)
AS distance')
)
->orderBy('distance', 'asc')
->get();
做,但它無法正常工作。
任何人都可以請幫忙嗎?
嗨,稍微更新一下,你可以看看嗎? –