代码点火器允许在插入查询中使用单引号


Codeigniter allowing single quote in insert query

你好,我读到"Codeigniter更新和插入函数值会自动转义,从而产生更安全的查询。"

但我试图在我的contactUs表单中插入带有单引号的数据。但我注意到在我的数据库中添加了单引号。

这是我的代码

控制器

        $data=array('name'=>$this->input->post('name'),'EmailId'=>$this->input->post('emailid'));
        $this->mymodel->insert_data('mytable',$data);//Sending data to the model

型号

    public function insert_data($table,$data)
{
    $this->db->insert($table,$data);
    return 'success.';
}

有什么建议吗???

提前感谢

如果事先正确转义了单引号,或者使用准备好的语句将其插入到表中,则单引号不是问题。完全去掉这些字符可能会违反数据完整性。