Welcome Guest, Not a member yet? Register   Sign In
how to disable escape queries
#1

[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.
#2

[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.




Theme © iAndrew 2016 - Forum software by © MyBB