地理距离搜索 MYSQL
我正在使用空间扩展使用 mysql 进行地理搜索。因为我做了一个存储过程(当我像这样在 mysql 的命令行上尝试时,它工作得非常好
mysql>称呼 test2(GeomFromText('点(-0.93961472 43.52843475)'),0.6);
DROP PROCEDURE `test2`//
CREATE DEFINER=`root`@`localhost` PROCEDURE `test2`(IN center2 point,IN dist int)
BEGIN
SET @center = center2;
SET @radius = dist;
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 professionnels.*, AsText(coord)
FROM professionnels
WHERE Intersects( coord, GeomFromText(@bbox) )
AND SQRT(POW( ABS( X(coord) - X(@center)), 2) + POW( ABS(Y(coord) - Y(@center)), 2 )) < @radius limit 20;
end
但问题是我需要从 php.ini 调用它。当我这样做时,返回一个错误说
PROCEDURE test2 无法返回结果 在给定上下文中设置
那么..我如何使用转身来返回一组数据?
谢谢
I'm doing a geo search with mysql using the spatial extension. FOr that i did a stored procedure (thats work really well when i tri on command line in mysql like that
mysql> CALL
test2(GeomFromText('POINT(-0.93961472
43.52843475)'),0.6 );
DROP PROCEDURE `test2`//
CREATE DEFINER=`root`@`localhost` PROCEDURE `test2`(IN center2 point,IN dist int)
BEGIN
SET @center = center2;
SET @radius = dist;
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 professionnels.*, AsText(coord)
FROM professionnels
WHERE Intersects( coord, GeomFromText(@bbox) )
AND SQRT(POW( ABS( X(coord) - X(@center)), 2) + POW( ABS(Y(coord) - Y(@center)), 2 )) < @radius limit 20;
end
But the problem is that i need to call that from php. and when i do it, an error is return said that
PROCEDURE test2 can't return a result
set in the given context
So.. How can i use a turn around to return a set of data ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将最后一部分更改为
然后您可以从 temp_table 中进行选择并在那里找到结果集。
You can change the last part into
Then you can select from the temp_table and find resultset there.