当我在我的"location"列(我的"旅程"表中的POINT数据类型)上运行此操作时,我似乎返回了一个意外的数字格式(PHP/Codeigniter):
$this->db->select('X(location)');
$query = $this->db->get('journeys');
例如,我得到了-5.52512112317928e-305,而我期望的是51.5…
"位置"的值插入如下:
$this->db->set('location','geomfromtext("POINT(lat lng)")',false);
我确信这是一个简单的数字格式问题,但我被难住了。
在输入数据点的行中:
$this->db->set('location','geomfromtext("POINT(lat lng)")',false);
我认为你并没有向我们展示你正在使用的代码,它看起来更像这样:
$this->db->set('location','geomfromtext("POINT('.$lat.' '.$lng.')")',false);
也许你应该根据你想要的精度来很好地格式化你的输入。可能是这样的:
$this->db->set('location','geomfromtext("POINT('.number_format($lat,6,'.','').' '.number_format($lng,6,'.','').')")',false);