=4" 'Query1' 的 Eloquent ORM 实现 $searchResults = Searc-6ren">
gpt4 book ai didi

php - 使用 Laravel Eloquent ORM 实现 MySQL Spatial 函数

转载 作者:可可西里 更新时间:2023-11-01 08:05:42 26 4
gpt4 key购买 nike

查询 1:

"SELECT * from search_table WHERE column>=4"

'Query1' 的 Eloquent ORM 实现

$searchResults = SearchTempTable::select(*);

$searchResults = $searchResults->where('column', '>=', 4);

查询 2:

"SELECT * FROM search_table WHERE ST_Intersects(column, geomfromtext( 'POLYGON(($point1X $point1Y, $point2X $point2Y, $point3X $point3Y,$point4X $point4Y,$point1X $point1Y))'))"

“查询 2”如何在 Eloquent ORM 中实现?

最佳答案

只有 raw 语句适用于此。

$bindings = [$point1X, $point1Y, ... ];

SearchTempTable::whereRaw(
"ST_Intersects(column, geomfromtext( 'POLYGON((? ?, ? ?, ? ?, ? ?, ? ?))' ))",
$bindings
)->get();

关于php - 使用 Laravel Eloquent ORM 实现 MySQL Spatial 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27539985/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com