开发者

How to remove single quotes that is automatically inserted in codeigniter?

How to prevent in codeigniter to not insert single开发者_开发百科 quotes around in our query?

When we write query in codeigniter it inserts automatically single quotes, like this:

 $this->db->select('id, ifnull(name,\'\') as name');
 $this->db->from('table');

which creates database error.


 $this->db->select('id, ifnull("name",\'\') as name', false);
 $this->db->from('table');

Is what you're after. The quotes are escaping to stop sql injection, be sure not to mix unsanitized input from the user.

I guess I should also note that using this false parameter will stop double quote encapsulation, if you're using postgres you'll probably need to encapsulate any kew words used as column names yourself. (see difference between name and "name")

Active Record - Selecting Data

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜