【问题标题】:PostGIS with Laravel使用 Laravel 的 PostGIS
【发布时间】:2017-04-19 15:10:34
【问题描述】:

由于某种原因,在 Laravel 中使用 ST_Intersects 会报错:

Undefined function: 7 ERROR: function st_intersects(public.geometry, public.geometry) does not exist

完全相同的查询,相同的数据库在普通 PHP 中运行良好。

完整的查询文本:

$query =
       "SELECT estado, municipio, COUNT(*)
        FROM public.focos_bdq, dados_geo.poligonos_deter
        WHERE ST_Intersects(focos_bdq.geometria, poligonos_deter.geom)
        AND bioma LIKE '$bioma_bd'
        AND date_trunc('month', data_hora_gmt)::date = '$mes_anterior'
        AND (satelite LIKE 'AQUA%' OR satelite LIKE 'TERRA%')
        GROUP BY municipio, estado
        ORDER BY COUNT(*) DESC";

$focos = \DB::select($query);

【问题讨论】:

    标签: php postgresql laravel geometry postgis


    【解决方案1】:

    也许您应该将模式名称 (postgis) 附加到函数名称。 postgis.ST_Intersects(...

    或者,laravel 登录的用户可能需要正确设置其架构搜索路径。

    【讨论】:

    • 不幸的是,附加架构没有帮助。如何验证 laravel 用户?
    • 我只是说 laravel 用来登录数据库的数据库用户,将在数据库配置文件中。另外,您可以通过打开 PG 日志记录或使用 laravel logger 记录 sql 并捕获发送到 DB 的 sql 吗?
    猜你喜欢
    • 2017-08-12
    • 1970-01-01
    • 2019-02-25
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    • 1970-01-01
    • 2021-04-25
    • 2019-02-23
    相关资源
    最近更新 更多