2
私はEloquentを使用してデータベースからデータを取得しています。私のデータベースには、POINT
データ型を使用する列があります。列の値はPOINT(52.45083 -1.930546)
です。EloquentがPOINTデータをUTF8として返します
私はこのデータをデータベースから取得し、それをJSONとして返します。 POINT
データを含む。しかし、Eloquentは次の形式で返します。
array(7) {
["id"]=>
int(2)
["city_id"]=>
int(1)
["image"]=>
NULL
["name"]=>
string(20) "University of London"
["geo_coords"]=>
string(25) "ͯ���[email protected]�h�^`V��"
["created_at"]=>
string(19) "2017-01-11 10:53:46"
["updated_at"]=>
NULL
}
これはなぜですか?
雄弁者がPOINTデータをサポートしているかどうかはわかりません。 https://laravel.com/docs/5.0/eloquent#accessors-and-mutatorsは、モデルを変換するうえで便利な方法です。 – apokryfos
が役に立ちます:http://stackoverflow.com/questions/30682538/handling-mysql-spatial-datatypes-in-laravel-eloquent-orm – nogad