Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在zend中使用regexp防止sql注入plus_Regex_Zend Framework_Sql Injection_Zend Db - Fatal编程技术网

在zend中使用regexp防止sql注入plus

在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

我希望防止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 '^$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.'$'));