使用 insert()、update()、where()、order_by() 等函数时,CodeIgniter 会自动阻止 SQL 注入吗?

Does CodeIgniter automatically prevent SQL injection when using function like insert(), update() , where(), order_by()?

注意:我的问题是不是Does CodeIgniter automatically prevent SQL injection? or how to avoid sql injection in codeigniter的重复问题,因为它询问了query()函数。我问的是 insert(), update() , where(), order_by()?

这样的函数

我问以下类型的查询也会自动防止 SQL 注入?

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();

假设所有变量都是GET或POSTS值。

CodeIgniter 的 Active Record 方法 https://www.codeigniter.com/userguide2/database/active_record.html 自动为您转义查询,以防止注入。

您可以在这里找到答案