I want to prevent sql injection as well as want to use REGEXP to get similar results in the same query. I know I prevent sql injection like this
$this->getAdapter()->fetchAlll("SELECT * FROM $this->_table WHERE email = ? ", array($email));
Now I have another query in which I am using REGEXP to get similar results on the basis of first 3 and last three characters. My query looks like this
$this->_adapter->fetchAll("SELECT country_name FROM $this->_name WHERE country_name REGEXP '^$front' OR country_name REGEXP '$end$'");
Putting ^ in begin while using REGEXP means you want to compare from start and using $ at end means you want to compare from end.
So Now I want to ask how can I write the above query to prevent sql injection as of the above query?