Codeigniter - 使用两个喜欢和在一起的地方

Mah*_*deh 5 php sql codeigniter

我有一个问题,使用两个像声明和在一起:

    $this->db->select('something');
    $this->db->where('WHERE',$var);
    $this->db->where_in('WHEREIN', $var);
    $this->db->like('LIKE1',$query);
    $this->db->or_like('LIKE2',$query);
    $query = $this->db->get('table');
Run Code Online (Sandbox Code Playgroud)

我的查询必须选择LIKE1LIKE2在哪里WHEREWHEREIN是真的.

如果我使用or_like,where声明也得到or,

如果我只使用它like,它就成了like AND like声明

任何解决方案

Mah*_*deh 5

我找到了这个解决方案

使用group_start()group_end(),所以我的代码转向

$this->db->select('something');
$this->db->where('WHERE',$var);
$this->db->where_in('WHEREIN', $var);
$this->db->group_start();
$this->db->like('LIKE1',$query);
$this->db->or_like('LIKE2',$query);
$this->db->group_end();
$query = $this->db->get('table');
Run Code Online (Sandbox Code Playgroud)