Codeigniter Delete … Where … and

后端 未结 3 535
我寻月下人不归
我寻月下人不归 2021-01-27 00:27

I need a little help. How can i send this query with codeigniter?

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

相关标签:
3条回答
  • 2021-01-27 00:41
    $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 is also an alternative:

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

    This also:

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

    More info: here

    0 讨论(0)
  • 2021-01-27 00:55

    Just use this $this->db->query("Delete FROM friendconnect WHERE who = 5 and whos = 1 OR whos = 5 and who = 1");

    0 讨论(0)
  • 2021-01-27 01:04
    $this->db->where('(who = 5 and whos = 1) OR (whos = 5 and who = 1)');
    $this->db->delete('friendconnect');
    
    0 讨论(0)
提交回复
热议问题