$this->db->escape() function adding single quote in codeigniter $this->db->escape() function adding single quote in codeigniter codeigniter codeigniter

$this->db->escape() function adding single quote in codeigniter


When you use the query builder class to construct your queries the values are escaped automatically by the system so you don't have to use the function $this->db->escape. In your case, each value was escaped by the escape function and the system did it again for each value when executing the insert function.

Now if you want to run custom queries using the function $this-db->query it is a good practice to escape the data like bellow:

$sql = "INSERT INTO table (column) VALUES(".$this->db->escape($value).")";$this->db->query($sql);