1

Note :My question is not a duplicate question for Does CodeIgniter automatically prevent SQL injection? or how to avoid sql injection in codeigniter because it asked query() function. I am asking function like insert(), update() , where(), order_by()?

I am asking that following types of queries also automatically prevent SQL injection?

01.

$data = array(
        'title' => $title,
        'name' => $name,
        'date' => $date
);

$this->db->where('school', $school);
$this->db->update('mytable', $data);

02

$this->db->select('*');
$this->db->from('table_name');
$this->db->where('pro_name', $pro_name);        
$this->db->order_by($pro_type, 'desc');
$query = $this->db->get();
return $query->result_array();

Assume that all variables are GET or POSTS values.

3
  • Possible duplicate stackoverflow.com/questions/5857386/… Commented Jun 6, 2017 at 4:31
  • 2
    @GhanshyamBhava It is not a duplication question too that quetion too because it is also asked the query() function. I am asking about function like` insert(), update() , where(), order_by()`? Commented Jun 6, 2017 at 4:34
  • Does this answer your question? how to avoid sql injection in codeigniter Commented Nov 14, 2021 at 19:41

1 Answer 1

1

CodeIgniter's Active Record methods https://www.codeigniter.com/userguide2/database/active_record.html automatically escape queries for you, to prevent injection.

You may find answer in here https://stackoverflow.com/a/5857481/4895810

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.