I am working with codeigniter / SQL. Where I want to insert unicode string with ‘N’ Prefix the insert. How can I achieve it in regular insert.
Regular Code:
$data = array( 'title' => 'My title' , 'name' => 'My Name' , 'data' => 'My data' ); $this->db->insert('mytable', $data);
INSERT Trying to Achieve:
INSERT INTO mytable (title, name, data) VALUES ('My title','My Name',N'My data');
Is there any way to achive the above insert instead of manually writing the Query.?
Advertisement
Answer
This is the simplest way to do it.
$data = array( 'title' => 'My title' , 'name' => 'My Name' , 'data' => 'N'.'My data' ); $this->db->insert('mytable', $data);
Or, if the prefix needs to more dynamic do this
$pre = foo(bar); $data = array( 'title' => 'My title' , 'name' => 'My Name' , 'data' => $pre.'My data' ); $this->db->insert('mytable', $data);