hi,
I’m a yii newbie, and fighting with spatial data in table under yii. I have table
CREATE TABLE `locations` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`position` point NOT NULL,
`radius` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
normal view method was not able to view date and thrown exception, I’ve done it in this way
public function beforeFind()
{
$criteria = new CDbCriteria;
$criteria->select = "id,name, astext(position) AS position, radius";
$this->dbCriteria->mergeWith($criteria);
}
I hope it’s quite correct with yii philosophy, but generally works and for example under gridview in column position I receive strings with geoms from table. In this case points like POINT(xx.xxx yy.yyy). For me it’s ok.
I have problem with create and update record. I’ve tried beforeSave with string modification to GeomFromText(‘POINT(xx.xxx yy.yyy)’) but without success. Every time I receive
CDbCommand failed to execute the SQL statement: SQLSTATE[22003]: Numeric value out of range: 1416 Cannot get geometry object from data you send to the GEOMETRY field. The SQL statement executed was: INSERT INTO `locations` (`name`, `position`, `radius`) VALUES (:yp0, :yp1, :yp2)
any helpfull hand with solution?