CodeIgniter Active Record 不相等

问题描述:

在使用活动记录的 CodeIgniter 中,如何在 $this->db->where() 中执行不等于.例如:

In CodeIgniter using active record, how do I perform a not equal to in $this->db->where(). For instance:

$this->db->where('emailsToCampaigns.campaignId', $campaignId);

会做等于,但我不需要等于.我试过了:

Will do equal to, but I need not equal to. I have tried:

$this->db->where('emailsToCampaigns.campaignId <> ', $campaignId);
$this->db->where('emailsToCampaigns.campaignId != ', $campaignId);
$this->db->where('emailsToCampaigns.campaignId', ' != ' . $campaignId);
$this->db->where('emailsToCampaigns.campaignId != ' . $campaignId);

一切都没有运气.想法?

All with no luck. Ideas?

根据手册,这应该可行:

According to the manual this should work:

自定义键/值方法:

您可以在第一个参数中包含一个运算符以控制比较:

You can include an operator in the first parameter in order to control the comparison:

$this->db->where('name !=', $name);
$this->db->where('id <', $id);
Produces: WHERE name != 'Joe' AND id < 45

搜索 $this->db->where(); 并查看第 2 项.

Search for $this->db->where(); and look at item #2.