Codeigniter Delete … Where … and

血红的双手。 提交于 2021-02-17 03:22:21

问题


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;

I found only that:

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

Thanks everybody!


回答1:


$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




回答2:


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




回答3:


$this->db->where('(who = 5 and whos = 1) OR (whos = 5 and who = 1)');
$this->db->delete('friendconnect');


来源:https://stackoverflow.com/questions/32332450/codeigniter-delete-where-and

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!