如何使用 codeigniter 在 mysql 几何列中插入多边形点?
how do i insert a polygon point in mysql geometric column using codeigniter?
我的代码有什么问题?
$this->db->query("update profile set polygon = POLYGON((0 0,82 33,23
66,0 0)) where id = 1");
多边形是一列,类型为几何(多边形)。
我将此 "POLYGON((0 0,82 33,23 66,0 0))" 粘贴到 phpmyadmin 的那个列中,它已保存但无法查询它
试试这个 - 它使用我喜欢的查询生成器(Codeigniter 的一部分)!!
$this->db->set('polygon','POLYGON(0 0,82 33,23 66,0 0)',false);
$this->db->where('id',1);
$this->db->update('profile');
请注意 false
从 quoting/escaping 您的查询中停止 CI。显然,如果您在那里接受用户提供的信息 - 那么必须检查 SQL 在其他地方注入或修改此查询。
我找到了答案
$this->db->query("update profile set polygon = ST_GeomFromText('POLYGON((0 0,82 33,23 66,0 0))') where id = 1");
我的代码有什么问题?
$this->db->query("update profile set polygon = POLYGON((0 0,82 33,23 66,0 0)) where id = 1");
多边形是一列,类型为几何(多边形)。 我将此 "POLYGON((0 0,82 33,23 66,0 0))" 粘贴到 phpmyadmin 的那个列中,它已保存但无法查询它
试试这个 - 它使用我喜欢的查询生成器(Codeigniter 的一部分)!!
$this->db->set('polygon','POLYGON(0 0,82 33,23 66,0 0)',false);
$this->db->where('id',1);
$this->db->update('profile');
请注意 false
从 quoting/escaping 您的查询中停止 CI。显然,如果您在那里接受用户提供的信息 - 那么必须检查 SQL 在其他地方注入或修改此查询。
我找到了答案
$this->db->query("update profile set polygon = ST_GeomFromText('POLYGON((0 0,82 33,23 66,0 0))') where id = 1");