Tuesday, April 10, 2012

Re: Insert into postgres table with postgis extension

I found the solution of my problem:

Just only use the static method DboSource::expression()

http://api20.cakephp.org/class/dbo-source#method-DboSourceexpression

Em domingo, 8 de abril de 2012 07h38min19s UTC-3, Everton Inocencio escreveu:
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

Em domingo, 8 de abril de 2012 07h38min19s UTC-3, Everton Inocencio escreveu:
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: