在zend中使用regexp防止sql注入plus
我希望防止sql注入,并希望使用在zend中使用regexp防止sql注入plus,regex,zend-framework,sql-injection,zend-db,Regex,Zend Framework,Sql Injection,Zend Db,我希望防止sql注入,并希望使用REGEXP在同一查询中获得类似的结果。我知道我会像这样阻止sql注入 $this->getAdapter()->fetchAlll("SELECT * FROM $this->_table WHERE email = ? ", array($email)); $this->_adapter->fetchAll("SELECT country_name FROM $this->_name WHERE country_name
REGEXP
在同一查询中获得类似的结果。我知道我会像这样阻止sql注入
$this->getAdapter()->fetchAlll("SELECT * FROM $this->_table WHERE email = ? ", array($email));
$this->_adapter->fetchAll("SELECT country_name FROM $this->_name WHERE country_name REGEXP '^$front' OR country_name REGEXP '$end$'");
现在我有了另一个查询,我使用REGEXP
在前3个字符和后3个字符的基础上得到类似的结果。我的问题是这样的
$this->getAdapter()->fetchAlll("SELECT * FROM $this->_table WHERE email = ? ", array($email));
$this->_adapter->fetchAll("SELECT country_name FROM $this->_name WHERE country_name REGEXP '^$front' OR country_name REGEXP '$end$'");
当使用REGEXP
时,将^
放在begin中表示您希望从开始进行比较,而在末尾使用$
表示您希望从结尾进行比较
因此,现在我想问一下,如何编写上述查询以防止上述查询中的sql注入?尝试以下操作
$query = "SELECT country_name
FROM $this->_name
WHERE country_name REGEXP ? OR
country_name REGEXP ?";
$this->_adapter->fetchAll($query, array('^'.$front, $end.'$'));