Codeigniter Active Record 'where_or' grouping

前端 未结 3 1779
你的背包
你的背包 2020-12-11 04:00

Is it possible to group and_where / or_where / or_like... statements together so as not to mix with other and/where statements.

Something that would result

3条回答
  •  我在风中等你
    2020-12-11 04:25

    These two functions group_start() and group_end() have been implemented in CodeIgniter 3.0.3. Here is little better implementation according to the original question.

    $name1 = 'Bob';
    $name2 = 'John';
    
    $this->db->where('city', 'My City');
    $this->db->where('state', 'My State');
    $this->db->group_start();
    $this->db->like('name', $name1);
    $this->db->or_like(('name', $name2);
    $this->db->group_end();
    

提交回复
热议问题