代码点火器$ this-> db-> query()或$ this-> db-> escape()会阻止SQL注入吗? [英] Does codeigniter $this->db->query() or $this->db->escape() prevent SQL Injection?
问题描述
我想问一下这两种方法 $ this-> db-> escape()
和 $ this-> db- > query()
I want to ask about these 2 method $this->db->escape()
and $this->db->query()
那些可以防止SQL注入吗?
Do those can prevent SQL Injection?
推荐答案
首先,您应该清楚什么是 db-> escape()
和 db-> query()
First of all, you should have clear idea of what is db->escape()
and db->query()
does.
用于使用 常规查询 ,而不是 查询生成器类 。当我们使用直接查询数据库时,存在高度的安全漏洞。因此,CI通过这些攻击获得了 escape()
的收益。并且 我们可以使用3种方法 和 escape()
就是其中之一 。
This used for users who use Regular Queries rather Query Builder Class. When we use a direct query to DB, there is a high vulnerability to security. So CI made escape()
from those attacks. And there are 3 methods we can use and escape()
is one of them.
此方法已添加到 版本1.5.0 并且它仍然存在于CI数据库类中,并且在v1.5-V3.0(v4也是如此)中进行了重大改进。用于执行 复杂查询 和 SP ,并且可以更好地理解。此方法 只要在此<$ c $内部执行任何查询c> query() ,它没有 没有任何SQL注入预防措施 。
This method was added to version 1.5.0 and it's still there in CI database class with major+minor improvements in v1.5 - V3.0( v4 too). This use to execute complex queries and SP in an easy way with better understanding. This method just run a query whatever inside this query()
and it has no any SQL injection preventation.
否为了使用这些 转义方法 在CI中, strong>必须使用 query()
。 escape()
, escape_str()
和 escape_like_str()
被添加到SQL查询中,显然他们需要 query()
来执行任何类型的操作。
No. In order to use these Escaping methods in CI, you have to use query()
. escape()
, escape_str()
and escape_like_str()
were added to SQL queries and obviously they need query()
to perform any sort of action.
是课程。他们在那里帮助提高安全性。并阅读 输入安全过滤 post( 'some_data',TRUE);
和安全性以更好地理解。
Yes of course. They're there to help with security. And read Input Security Filtering post('some_data', TRUE);
and Security for better understanding.
这篇关于代码点火器$ this-> db-> query()或$ this-> db-> escape()会阻止SQL注入吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!