Search by like db in mysql

1

my question is the following I have a problem what happens that I try to pass two ways of obtaining values through like both by description and by codbar. the code is as follows

this is the code that seeks me by description

 $this->db->select('*');
        $this->db->limit(10);
        $this->db->like('descripcion', $q);
        $query = $this->db->get('produtos');

this is the code that seeks me for codbar

 $this->db->select('*');
        $this->db->limit(10);
        $this->db->like('codbar', $q);
        $query = $this->db->get('produtos');

So I try to put both but do not look for me for both, just for coding

 $this->db->select('*');
        $this->db->limit(10);
        $this->db->like('descripcion | codbar', $q);
        $query = $this->db->get('produtos');

I appreciate your help, thank you.

    
asked by miguel 12.11.2018 в 01:59
source

1 answer

1

The documentation of explain it clearly, you need to use

or_like()

  

This method is identical to the one above, except that multiple   instances are joined by OR:

combined with% normal% co.

Something like this:

$this->db->like('descripcion', $q); 
$this->db->or_like('codbar', $q);
    
answered by 12.11.2018 в 02:35