skip to Main Content

what is wrong with my code?

$this->db->query(“update profile set polygon = POLYGON((0 0,82 33,23
66,0 0)) where id = 1”);

polygon is a column with type of geometric(polygon).
i paste this “POLYGON((0 0,82 33,23 66,0 0))” in that column in phpmyadmin and it is saved but wuth query it in not work

2

Answers


  1. Chosen as BEST ANSWER

    I found the answer

    $this->db->query("update profile set polygon = ST_GeomFromText('POLYGON((0 0,82 33,23 66,0 0))') where id = 1");
    

  2. Try this – it uses Query Builder (part of Codeigniter) of which I am a fan!!

    $this->db->set('polygon','POLYGON(0 0,82 33,23 66,0 0)',false);
    $this->db->where('id',1);
    $this->db->update('profile');
    

    Note the false stops CI from quoting/escaping your query. Obviously if you accept user supplied information in there – then this would have to be checked for SQL injection elsewhere or this query amended.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search