如何使用 CodeIgniter 的 where() 方法编写不相等条件?
在使用活动记录的 CodeIgniter 中,如何在 $this->db->where()
中执行不等于。例如:
$this->db->where('emailsToCampaigns.campaignId', $campaignId);
会等于,但我不需要等于。我已经尝试过:
$this->db->where('emailsToCampaigns.campaignId <> ', $campaignId);
$this->db->where('emailsToCampaigns.campaignId != ', $campaignId);
$this->db->where('emailsToCampaigns.campaignId', ' != ' . $campaignId);
$this->db->where('emailsToCampaigns.campaignId != ' . $campaignId);
都没有运气。有想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
根据手册,这应该有效:
搜索
$this->db->where();
并查看项目 #2 。According to the manual this should work:
Search for
$this->db->where();
and look at item #2.它对我来说效果很好,
或者尝试这个,
或者尝试这个,
一切都会起作用。
It worked fine with me,
Or try this one,
Or try this one,
all will work.
试试这个代码。
这似乎适用于我的情况。
Try this code.
This seems working in my case.
这应该有效(您已经尝试过)
要调试,您可以在执行查询后放置此代码以查看它生成的确切 SQL,这可能会给您提供线索,您可以将其添加到问题中以获取进一步的帮助。
This should work (which you have tried)
To debug you might place this code just after you execute your query to see what exact SQL it is producing, this might give you clues, you might add that to the question to allow for further help.
这应该有效(你已经尝试过)
This should work (which you have tried)
以下是 codeigniter 文档中的示例
在此处输入图像描述
Here is an example from the codeigniter documentation
enter image description here