如何在codeigniter中的两个OR_LIKE查询之间执行AND操作

问题描述:

I perform a multiple search using multiple join query in code igniter so i perform 3 or_like query.But there is an 'OR' placed in between each or_like query by default by code igniter.But actualy i want to perform 'AND' Operation Between them.Please help me. Thanks

我在代码点火器中使用多个连接查询执行多重搜索,所以我执行3个or_like查询。但是有一个' 或者'默认放置在每个or_like查询之间由代码igniter.But实际上我想在它们之间执行'AND'操作。请帮助我。 谢谢 p> div>

We can do it very simply in codeigniter version 3.0

eg,

    $this ->db ->select('*');
    $this ->db ->where('age',$age);
    $this ->db ->where('country',$country);
    $this->db->group_start();
    $this ->db ->or_where('state',$state);
    $this ->db ->or_where('district',$district);
    $this->db->group_end();
    $query=$this ->db ->get('pg_reg');

or_like is provided by codeignitor to multiple instances are joined by OR. So, I think there is no way to replace OR by AND. Here is another solution that you can try.

Instead using "like" and "or_like" use where clause as below

$this->db->where('location LIKE', '%'.$your_location.'%');
$this->db->where('city LIKE', '%'.$your_city.'%');