Handling spatial data in CakePHP

99封情书 提交于 2019-12-10 11:58:03

问题


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 nodes (Location) VALUES (GeomFromText('POINT(42.450071 -76.487664)'))

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.

Thanks for any insight.

-Andrew


回答1:


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

e.g. something along the lines of:

$gLat = 42.450071;
$gLong = -76.487664;
$this->Node->query("INSERT INTO nodes (Location) VALUES (GeomFromText('POINT({$gLat} {$gLong})'))");


来源:https://stackoverflow.com/questions/4598834/handling-spatial-data-in-cakephp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!