Sunday, April 8, 2012

Insert into postgres table with postgis extension

I'm using CakePHP 2.1.1 and PostgreSql 9.1.

And I'm trying to use the save() method of my Model, but one column need
to use a DB function to convert a value to insert.

Ex:
Array(
'Ponto' => Array(
  'id' => '',
   'title' => ' default title ',
   'ponto' => "ST_GeomFromText('POINT(1 1)', 4326)"
)
);

My field 'ponto' has to execute a ST_GeomFromText() function before put value, 
but the generated SQL looks like this:

INSERT INTO pontos (title, ponto, created) VALUES ('default title', 'ST_GeomFromText(\'POINT(1 1)\',  4326)', NOW() );
But this not works.

Has a way to cakephp not to escape my value as a string ?

INSERT INTO pontos (title, ponto, created) VALUES ('default title'ST_GeomFromText('POINT(1 1)',  4326, NOW() );
I want this 

Thanks,
sorry for my bad english :x

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
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

No comments: