在CakePHP中保存空间数据

5 php mysql cakephp spatial cakephp-2.3

我在使用saveAll()在CakePHP中保存空间数据时遇到问题.我真的不想手动编写查询(处理CakePHP中的空间数据),因为有许多模型被保存.

我还读了这个CakePHP和MySQL Spatial Extension,但是当我尝试做同样的事情时,$db->expression()返回一个stdClass.

这是打印出来的返回对象:

stdClass Object
(
    [type] => expression
    [value] => GeomFromText('POINT(48.18879 18.527579999999944)')
)
Run Code Online (Sandbox Code Playgroud)

如果我在CakePHP和MySQL Spatial Extension中使用它的方式,并尝试使用saveAll()保存它我得到此错误:

错误:无法使用stdClass类型的对象作为数组
文件:/www/s/t/u47728/public_html/lib/Cake/Model/Model.php
行:2221

如果我使用value属性,它会在查询中转义,因此它只是一个字符串.然后我收到这个错误:

错误:SQLSTATE [22003]:数值超出范围:1416无法从发送到GEOMETRY字段的数据中获取几何对象

saveAll()是否支持表达式?

UPDATE

显然同样适用于save()函数和其他....还saveField()

Ara*_*avi 6

转换这一行:

$this->data['Report']['position'] = $db->expression("GeomFromText('POINT(" . 
    $this->data['Report']['lat'] . " " . $this->data['Report']['lng'] . ")')");
Run Code Online (Sandbox Code Playgroud)

至 :

$this->data['Report']['position'] = (object) $db->expression("GeomFromText('POINT(" .
     $this->data['Report']['lat'] . " " . $this->data['Report']['lng'] . ")')");
Run Code Online (Sandbox Code Playgroud)

它应该工作.