Wednesday, January 5, 2011

Re: Handling spatial data in CakePHP

On Jan 5, 3:01 pm, ehrlichja <ehrlic...@gmail.com> wrote:
> 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.

look in the cake source/test cases for any example using $db-
>expression

your code should be similar, something like

$this->save(array('lat' => $db-
>expression("GeomFromText('POINT(42.450071, -76.487664)')"));

rgrds,

AD

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: