I am working on codeigniter project. How can I know queries function in my models are preventing the sql injection. Even I'm using different ways to insert data but how can i make sure that which one is safe .
Here's my code:
1) *****************
$data = array(
'name' => $_POST['name'],
'email' => $_POST['email'],
'phone' => $_POST['phone'],
'city' => $_POST['city'],
'current_salary' => $_POST['current_salary'],
'expected_salary' => $_POST['expected_salary'],
'reume_link' => $file_name,
'status' => 0,
);
$this->db->insert('my_table_name', $data);
2) **************************
$query = $this->db->query('SELECT distinct(name) as name FROM `my_table_name` WHERE city like "%'.$_POST['state'].'%" ');
$res = $query->result_array();
3) **************************
$query = $this->db->query("insert into my_table_name(nid,sid,cid,data) values('766','$sid',1,'".$_POST['adm_name']."')");
Are the codeigniter function prevent sql injection default or I strictly need to use prepare statement / bind parameter.
Are the simple CI function not safe to use ?