CodeIgniter Forums

Full Version: Manipulating the way a db Query is generated ..
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Hi, is there a way to manipulate the way a db query is built .. I would like to use the LIKE operator with a wildcard `%` instead of the equal `=` operator to generate queries like
SELECT * FROM (`drivers`) WHERE `first_name` LIKE 'D%' AND `active` = 1 ORDER BY `id`

instead of
SELECT * FROM (`drivers`) WHERE `first_name` = 'David' AND `active` = 1 ORDER BY `id`

This is how the query is being constructed from a search form

          $criteria[$this->searchfld[$i]]= $this->input->get($this->searchfld[$i]);

return $this->db->get();