簡體   English   中英

在PHP中形成MySQL查詢

[英]form mysql query in php

我有以下查詢,我需要在php中執行。 問題是我需要在執行主查詢之前設置查詢。 設置的查詢是

SET @center = GeomFromText('POINT(33.3666667 35.1666667)');   
SET @radius = 1;   
SET @bbox = CONCAT('POLYGON((',   
X(@center) - @radius, ' ', Y(@center) - @radius, ',',   
X(@center) + @radius, ' ', Y(@center) - @radius, ',',   
X(@center) + @radius, ' ', Y(@center) + @radius, ',',   
X(@center) - @radius, ' ', Y(@center) + @radius, ',',   
X(@center) - @radius, ' ', Y(@center) - @radius, '))'   
);  

主要查詢是

SELECT
users_profile.id,
GLength(LineString(users_profile.location,GeomFromText('POINT(33.3666667 35.1666667)'))) * 100 as distance

FROM 
users_profile

WHERE 
Intersects( users_profile.location, GeomFromText(@bbox))
AND (GLength(LineString(users_profile.location,GeomFromText('POINT(33.3666667 35.1666667)'))) * 100)  < 10

ORDER BY distance

如何在PHP中執行此操作? 我不能作為4個不同的查詢來做,也不能在1個中做

我認為您無法像這樣執行第一個查詢。 嘗試將其編寫為一個存儲過程,然后從PHP調用它。

我在這里找到了可能有幫助的東西。 我沒有使用或測試過,所以YMMV。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM