Handling spatial data in CakePHP

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Handling spatial data in CakePHP

ehrlichja
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

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 [hidden email]
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Handling spatial data in CakePHP

AD7six


On Jan 5, 3:01 pm, ehrlichja <[hidden email]> 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 [hidden email]
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en