Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value IS NOT NULL in codeigniter

Tags:

I am trying to create the following statement:

select * from donors where field is NOT NULL; 

With codeigniter, my code looks like this:

$where = ['field' => NULL]; $this->db->get_where('table', $where); 
like image 730
noushid p Avatar asked Oct 12 '15 08:10

noushid p


People also ask

Is null in CI?

Value IS NOT NULL in codeigniter.


1 Answers

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'); 
like image 175
Ari Djemana Avatar answered Oct 18 '22 00:10

Ari Djemana