问题描述
我有一个数据库,一个字段的空间数据和一个cakephp接口。在MySQL中,我可以通过执行以下操作保存数据:
I have a database with a field for spatial data and a cakephp interface for it. In MySQL I can save the data by doing:
INSERT INTO节点(位置)VALUES(GeomFromText('POINT(42.450071 -76.487664)'))
INSERT INTO nodes (Location) VALUES (GeomFromText('POINT(42.450071 -76.487664)'))
如何使Cake从网络表单中获取纬度和经度并以此方式插入?我做了一个读取空间数据的模型,但我不知道如何使它以空间格式写。
How can I make Cake take the latitude and longitude from a web form and insert it in this manner? I made a model that reads spatial data but I can't figure out how to make it write in spatial format.
感谢任何洞察力。
-Andrew
推荐答案
在手册中找到一点棘手,除非你知道寻找,但这应该帮助你:
It's a little tricky to find in the manual unless you know what to look for, but this should help you:http://book.cakephp.org/view/1027/query
例如
$gLat = 42.450071;
$gLong = -76.487664;
$this->Node->query("INSERT INTO nodes (Location) VALUES (GeomFromText('POINT({$gLat} {$gLong})'))");
这篇关于在CakePHP中处理空间数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!