riting a very simple search using like and have an option to omit options, however I find the like statement is making query ignore the where statement
$this->db->like('LOWER(location) OR LOWER(name)', strtolower($term));
$this->db->where('stage', 1);
$this->db->order_by("name", "asc");
$query = $this->db->get($this->user_table);
return $query->result();
Example of what the above produces with $term = "dublin";
SELECT * FROM (`users`) WHERE `stage` = 1 AND LOWER(location) OR LOWER(name) LIKE '%dublin%' ORDER BY `name` asc"
It still returns rows where 'stage' is not equal to 1.
Any ideas? Thank you!
$term = strtolower($term);
$this->db->where("(LOWER(location) LIKE '%{$term}%' OR LOWER(name) LIKE '%{$term}%')");
Substitute this for the query
$term = strtolower($term);
$this->db->where("stage= 1 AND (LOWER(location) LIKE '%{$term}%' OR LOWER(name) LIKE '%{$term}%')");
$query = $this->db->query("SELECT id_alimento, nombre, unidad, energia_kcal FROM catalogo_alimentos WHERE LOWER(nombre) LIKE '%".$this->db->escape_like_str($search)."%'");
if($query != false){
if ($query->num_rows() > 0) {
return $query->result();
}
}