Welcome Guest, Not a member yet? Register   Sign In
active record and escaping "%"
#1

[eluser]Krystian[/eluser]
Hi,

let`s say that we have such a code

Code:
function get_device( $options = array() )
{

  
  if(isSet($options['product_name']))
   $this->db->like('product_name', $options['product_name']);  
  
  
  $query = $this->db->get('products');
    
  
  return $query->result();
}

if product_name is set then this method produce such a query
Code:
SELECT * FROM (`products`) WHERE `product_name` LIKE '%sampleSname%'

when I leave type % post then the query looks
Code:
SELECT * FROM (`products`) WHERE `product_name` LIKE '%\%%'

so result is empty

how to return all rows in my case?





Theme © iAndrew 2016 - Forum software by © MyBB