【发布时间】:2017-02-01 21:25:24
【问题描述】:
我正在使用 Eloquent 从数据库中获取一些数据。我的数据库有一列使用 POINT 数据类型。这些列具有诸如POINT(52.45083 -1.930546) 之类的值。
我需要数据库中的这些数据,然后将其作为 JSON 返回。包括POINT 数据。但是,Eloquent 以以下形式返回它:
array(7) {
["id"]=>
int(2)
["city_id"]=>
int(1)
["image"]=>
NULL
["name"]=>
string(20) "University of London"
["geo_coords"]=>
string(25) "ͯ���I@�h�^`V��"
["created_at"]=>
string(19) "2017-01-11 10:53:46"
["updated_at"]=>
NULL
}
这是为什么?
【问题讨论】:
-
不确定 eloquent 是否支持 POINT 数据。 laravel.com/docs/5.0/eloquent#accessors-and-mutators 可能是转换模型的好方法。
标签: php mysql laravel eloquent