Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.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_Geolocation_Coordinates_Spatial - Fatal编程技术网

Php 地理距离搜索MYSQL

Php 地理距离搜索MYSQL,php,mysql,geolocation,coordinates,spatial,Php,Mysql,Geolocation,Coordinates,Spatial,我正在使用空间扩展使用mysql进行地理搜索。为此,我做了一个存储过程,当我在mysql中使用命令行时,它工作得非常好 mysql>呼叫 test2GeomFromText'点-0.93961472 43.52843475',0.6 ; 但问题是我需要从php调用它。当我这么做的时候,一个错误是 过程test2无法返回结果 在给定上下文中设置 所以。。如何使用掉头返回一组数据 谢谢您可以将最后一部分更改为 /*delete all rows from temp_table*/ DELETE FR

我正在使用空间扩展使用mysql进行地理搜索。为此,我做了一个存储过程,当我在mysql中使用命令行时,它工作得非常好

mysql>呼叫 test2GeomFromText'点-0.93961472 43.52843475',0.6 ;

但问题是我需要从php调用它。当我这么做的时候,一个错误是

过程test2无法返回结果 在给定上下文中设置

所以。。如何使用掉头返回一组数据


谢谢

您可以将最后一部分更改为

/*delete all rows from temp_table*/
DELETE FROM temp_table WHERE temp_table.somefield is not null;

INSERT INTO temp_table
  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;

然后,您可以从temp_表中选择并在那里查找结果集。

是的,但是如果有多个用户在进行搜索呢??这个搜索实际上是一个功能,允许用户搜索城市周围的一些POI,所以很多用户都会调用它。。。我不能用那种方法。。。它不行。。我使用了驱动程序MYSQLI,而不是MYSQL,它可以正常工作。我可以检索存储过程返回的数据集。但这是个好主意吗?Thanks@Fazoulete,这是一种黑客行为,但如果使用临时表,每个会话都会有自己的表,这样用户就不会看到彼此的结果。但是,如果直接从SP获得结果集,效果会更好。
/*delete all rows from temp_table*/
DELETE FROM temp_table WHERE temp_table.somefield is not null;

INSERT INTO temp_table
  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;