代码之家  ›  专栏  ›  技术社区  ›  vihkat

Codeigniter删除…其中…和

  •  1
  • vihkat  · 技术社区  · 9 年前

    我需要一点帮助。 如何使用codeigniter发送此查询?

    Delete FROM friendconnect WHERE who = 5 and whos = 1 OR whos = 5 and who = 1;
    

    我只发现:

    $this->db->where('id', $id);
    $this->db->delete('mytable'); 
    

    谢谢大家!

    3 回复  |  直到 9 年前
        1
  •  5
  •   viral    9 年前
    $this->db->where('who', 5);
    $this->db->where('whos', 1);
    $this->db->or_where('whos', 5);
    $this->db->where('who', 1);
    
    $this->db->delete('friendconnect');
    

    这也是一种选择:

    $this->db->where('who', 5)->where('whos', 1)->or_where('whos', 5)->where('who', 1);
    $this->db->delete('friendconnect');
    

    这也是:

    $this->db->where(array('who'=>5, array('whos'=>1)))->or_where('whos', 5)->where('who', 1);
    $this->db->delete('friendconnect');
    

    更多信息: here

        2
  •  -1
  •   Rahul Patel    9 年前

    就用这个 $this->db->query("Delete FROM friendconnect WHERE who = 5 and whos = 1 OR whos = 5 and who = 1");

        3
  •  -1
  •   Soorajlal K G    9 年前
    $this->db->where('(who = 5 and whos = 1) OR (whos = 5 and who = 1)');
    $this->db->delete('friendconnect');
    
    推荐文章