Codeigniter中的值不是NULL [英] Value IS NOT NULL in codeigniter
本文介绍了Codeigniter中的值不是NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建以下语句:
I am trying to create the following statement:
select * from donors where field is NOT NULL;
使用codeigniter,我的代码如下:
With codeigniter, my code looks like this:
$where = ['field' => NULL];
$this->db->get_where('table', $where);
推荐答案
when you see documentation You can use $this->db->where()
with third parameter set to FALSE to not escape your query.
Example:
$this->db->where('field is NOT NULL', NULL, FALSE);
或者您可以使用像这样的自定义查询字符串
Or you can use custom query string like this
$where = "field is NOT NULL";
$this->db->where($where);
因此您的查询生成器将如下所示:
So your query builder will look like this:
$this->db->select('*');
$this->db->where('field is NOT NULL', NULL, FALSE);
$this->db->get('donors');
OR
$this->db->select('*');
$where = "field is NOT NULL";
$this->db->where($where);
$this->db->get('donors');
这篇关于Codeigniter中的值不是NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文