codeigniter在sql查询中插入N Unicode文本 [英] codeigniter add N in sql Query INSERT unicode text
本文介绍了codeigniter在sql查询中插入N Unicode文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Codeigniter/SQL.在我想用``N''插入unicode字符串的地方插入的前缀.如何在常规插入中实现它.
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.
常规代码:
$data = array(
'title' => 'My title' ,
'name' => 'My Name' ,
'data' => 'My data'
);
$this->db->insert('mytable', $data);
INSERT尝试实现:
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.?
推荐答案
这是最简单的方法.
$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);
这篇关于codeigniter在sql查询中插入N Unicode文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文