Quantcast
Channel: Últimos conteúdos
Viewing all articles
Browse latest Browse all 14190

Usar Like para dois campos

$
0
0

Bom dia hoje tenho essa function 

 

    public function autoCompleteCliente($q){
 
        $this->db->select('*');
        $this->db->limit(10);
        $this->db->like('documento', $q);
        $query = $this->db->get('clientes');
        if($query->num_rows > 0){
            foreach ($query->result_array() as $row){
                $row_set[] = array('label'=>$row['nomeCliente'].' | CPF/CNPJ: '.$row['documento'],'id'=>$row['idClientes']);
            }
            echo json_encode($row_set);
        }
    }
 
No $this->db->like('descricao', $q); gostaria de fazer consulta em dois campo ex documento e nomeCliente
 
Vi na net que tem como fazer por and ex.
 
$this->db->like('title', 'match');
$this->db->like('body', 'match'); 
// WHERE title LIKE '%match%' AND body LIKE '%match%
 
 
 
Como fazer para OR ex 
 
WHERE clientes LIKE '%nomeCliente||documento%

Viewing all articles
Browse latest Browse all 14190

Trending Articles