• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Manipulating the way a db Query is generated ..

#1
[eluser]Unknown[/eluser]
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
Code:
SELECT * FROM (`drivers`) WHERE `first_name` LIKE 'D%' AND `active` = 1 ORDER BY `id`

instead of
Code:
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

Code:
..
      for($i=0;sizeof($this->searchfld)>$i;$i++)
        if($this->input->get($this->searchfld[$i])!=''){
          $criteria[$this->searchfld[$i]]= $this->input->get($this->searchfld[$i]);
        }

..
$this->db->where($criteria);
return $this->db->get();


Messages In This Thread
Manipulating the way a db Query is generated .. - by El Forum - 12-23-2011, 02:47 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.