Search code examples
phpmysqlsqlcodeignitersql-like

mysql query in codeigniter 3


I have the following problem, I have my consult in mysql

SELECT * FROM  noticias.historicos WHERE fecha LIKE '%2017-06-23%' AND ( titulo LIKE '%Chile%' OR bajadaNoticia LIKE '%Chile%')

its ok, I need transfer this query to mysql codeigniter query, thanks and have nice day


Solution

  • $query = $this->db
                  ->select('*')
                  ->from('noticias.historicos')
                  ->like('fetcha','2017-06-23')
                  ->group_start()
                  ->like('titulo', 'Chile')
                  ->or_like('bajadaNoticia', 'Chile')
                  ->group_end()
                  ->get();
    return $query->result(); //or return $query->result_array();
    

    try the above code or refer to this link here