Codeigniter允许插入查询中的单引号

时间:2013-11-20 12:26:09

标签: php mysql codeigniter

你好我读过“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.';
}

任何建议???

先谢谢

1 个答案:

答案 0 :(得分:1)

如果事先已正确转义或使用预准备语句将单引号插入表中,则单引号不是问题。完全剥离这些字符可能会违反数据完整性。