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

时间:2016-02-05 06:49:37

标签: php mysql codeigniter

我在代码点火器中使用多个连接查询执行多重搜索,所以我执行3 or_like查询。但是有一个' OR'默认情况下,代码igniter放置在每个or_like查询之间。但实际上我想执行' AND'他们之间的操作。请帮帮我。                    谢谢

2 个答案:

答案 0 :(得分:0)

or_like由codeignitor提供给多个实例,由OR连接。所以,我认为没有办法用AND代替OR。这是您可以尝试的另一种解决方案。

而是使用"喜欢"和" or_like"使用where子句如下

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

答案 1 :(得分:0)

我们可以在codeigniter 3.0版中非常简单地完成它。

例如

    $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');