开发者

zend framework with spatial

开发者 https://www.devze.com 2023-01-08 20:17 出处:网络
I am using zend framework with MySQL. I am using Zend_Db_Table_Abstract to run queries. I have a spatial field in a table :

I am using zend framework with MySQL. I am using Zend_Db_Table_Abstract to run queries. I have a spatial field in a table :

Country:

+------------+---------+------+-----+---------+----------------+
| Field      | Type    | Null | Key | Default | Extra          |
+------------+---------+------+-----+---------+----------------+
| id         | int(11) | NO   | PRI | NULL    | auto_increment |
| region_id  | int(5)  | NO   |     | NULL    |                |
| coordinate | point   | NO   | MUL | NULL    |                |
+------------+---------+------+-----+---------+----------------+

I'm trying to insert a record in this table but i got an error:

Zend_Db_Statement_Exception: SQLSTATE[22003]: Numeric value out of range: 1416 Cannot get geometry object from data you send to the GEOMETRY field .

by this:

$this->insert(array('region_id'=>'1','coordinate'=>开发者_运维百科;"GeomFromText( 'POINT(-12.461334 130.841904)'"));

Can anyone help?


$coordinate  = "GeomFromText( 'POINT(-12.461334 130.841904)')"; 

$this->insert(array('region_id'=>'1','coordinate'=>new Zend_Db_Expr($coordinate)));


Bill The Lizard got it right (yes, Oliver... he did mean "$coordinate", not "$spatial" on line 2).

I wanted my code all in one expression, so I used the following:

$this->insert(array(
'region_id'=>'1',
'coordinate'=>new Zend_Db_Expr("GeomFromText( 'POINT(-12.461334 130.841904)')")
));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号