如何防止codeigniter在我们的查询中不插入单引号?如何删除自动插入codeigniter中的单引号?
当我们编写查询在笨就会自动插入单引号,像这样:
$this->db->select('id, ifnull(name,\'\') as name');
$this->db->from('table');
它创建数据库错误。
如何防止codeigniter在我们的查询中不插入单引号?如何删除自动插入codeigniter中的单引号?
当我们编写查询在笨就会自动插入单引号,像这样:
$this->db->select('id, ifnull(name,\'\') as name');
$this->db->from('table');
它创建数据库错误。
$this->db->select('id, ifnull("name",\'\') as name', false);
$this->db->from('table');
是你在追求什么。引号是逃避停止sql注入,一定不要混合来自用户的unsanitized输入。
我想我还应该注意,使用这个false参数将停止双引号封装,如果您使用的是postgres,您可能需要封装任何用作列名称的关键字。 (见name
和"name"
之差)
它应该是什么样子? – Treffynnon
当我们执行它时,它添加了单引号错误的地方,即'table'.ifnull('name,'')作为名称'这里单引号需要围绕函数以及 – Suleman