我有一个表,其中有一列类型为 Spatial point ,,
我希望查询使用 laravel 插入该列的值
如果有查询以获取特定范围内的项目?
这里有什么帮助吗??
这是我的 table :
public function up()
{
Schema::create('markers', function(Blueprint $table)
{
$table->integer('marker_id')->primary();
$table->string('marker_name', 45);
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
});
DB::raw("ALTER TABLE markers ADD COLUMN location POINT");
}
最佳答案
您可以按如下方式插入数据:
ModelName::firstOrCreate(
array(
..//other fields
'location' => DB::raw("(GeomFromText('POINT(37.774929 -122.419415)'))")
)
);
检索数据:
SELECT X(`location`), Y(`location`) FROM markers;
我也被困在这里并得到了帮助:Spatial Point functions using Laravel Eloquent ORM .希望这会有所帮助。
关于mysql - 如何在 Laravel 的 MySQL 中通过查询插入 [Spatial Point] 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28645394/