Codeigniter删除...其中......和

时间:2015-09-01 13:03:54

标签: php sql codeigniter sql-delete

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

new ServiceTransformer<ReactivatePrepaidSubscriberInput, ReactivatePrepaidSubcriberOutput>(....){}

我发现只有:

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

谢谢大家!

3 个答案:

答案 0 :(得分:3)

$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

答案 1 :(得分:-1)

只需使用此$this->db->query("Delete FROM friendconnect WHERE who = 5 and whos = 1 OR whos = 5 and who = 1");

即可

答案 2 :(得分:-1)

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