Value IS NOT NULL in codeigniter

孤者浪人 提交于 2019-12-03 23:02:56

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');

Try this:

$this -> db -> get_where('donors', array('field !=' => NULL));

If you have some a complex query with multiple where and Having condition.

Please find below example:

$this->db->select(['id', 'email_address', 'abandon_at','datediff(now(),`abandon_at`) AS daysdiff ' ]); 
$this->db->having('daysdiff < 11');
$query = $this->db->get_where('forms', array('abandon_form' => 1,'abandon_at !=' => 'NULL') );   
return $query->result();

Try this:

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