我是codeigniter框架的新手,我做了几个查询我的问题是保持我的查询安全的最佳方式是什么。我应该使用mysql_real_escape_string
还是有一些更好的方法。 我用我的插入下面的代码:CodeIgniter中防止SQLInjection的最佳方法
function createCustomer($data){
$this->firstname = $data['firstname'];
$this->lastname = $data['surname1'].' '.$data['surname2'];
$this->address = $data['adres'];
$this->zipcode = $data['zipcode'];
$this->mail = $data['mail'];
$this->phonenumber = $data['phonenumber'];
$this->db->insert('Klant',$this);
//Check if the change was succesfull
return ($this->db->affected_rows() != 1) ? false : true;
}
而下面的代码得到:
function getUserByName($firstname, $lastname){
$query = $this->db->get_where('Customer', array('firstname' => $firstname, 'lastname' => $lastname));
return $query->result();
}
什么是防止SQL注入的最佳方式?任何提示都欢迎。
http://stackoverflow.com/questions/1615792/does-code-igniter-automatically-prevent-sql-injection不,你不使用mysql _ *()函数。它们已过时并已弃用。 –
我错过了这个问题,现在我会读它,谢谢你的链接。我会记住这一点 – RDAxRoadkill
它已经内置到框架中。 – Sparky