CodeIgniter Forums
how to disable escape queries - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: how to disable escape queries (/showthread.php?tid=8570)



how to disable escape queries - El Forum - 05-22-2008

[eluser]dreamynsx[/eluser]
By default Ci escape DB queries. How can I tell a given insert using CI db lib to not escape my inserts? I need to insert a javascript snippet thorugh a form and save it to db but it isn't saving it.


how to disable escape queries - El Forum - 05-22-2008

[eluser]gtech[/eluser]
I think you use $this->db->set and the third parameter FALSE stop CI escaping the value.
Code:
$this->db->set('field', 'value', FALSE);
$this->db->insert('mytable');


Quote:The CI documentation
set() will also accept an optional third parameter ($escape), that will prevent data from being escaped if set to FALSE. To illustrate the difference, here is set() used both with and without the escape parameter.

$this->db->set('field', 'field+1', FALSE);
$this->db->insert('mytable');
// gives INSERT INTO mytable (field) VALUES (field+1)

$this->db->set('field', 'field+1');
$this->db->insert('mytable');
// gives INSERT INTO mytable (field) VALUES ('field+1')

hope that resolves your problem.