Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中的表单mysql查询_Php_Mysql - Fatal编程技术网

php中的表单mysql查询

php中的表单mysql查询,php,mysql,Php,Mysql,我需要在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(@cente

我需要在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
选择
用户_profile.id,
GLength(线串(用户配置文件位置,GeomFromText('POINT(33.36667 35.1666667)))*100作为距离
从…起
用户档案
哪里
相交(用户_profile.location,GeomFromText(@bbox))
和(GLength(线串(用户配置文件位置,GeomFromText('POINT(33.3666667 35.1666667)))*100)<10
按距离排序

如何在PHP中执行此操作?我不能将其作为4个不同的查询来执行,也不能在1中执行。我认为您不能像这样执行第一个查询。尝试将其作为一个存储过程编写,然后从PHP调用。

我发现了一些可能有用的东西。我没有使用或测试它,所以YMMV。

我还是选择了mysqli的方式。由于mysqli执行多个查询的方式,这远远不够理想。理想情况是将4个查询改为1,但我所有的测试都失败了。