2015-10-12 22 views
5

CodeIgniter'daki IS NOT NULL: CodeIgniter ileDeğer aşağıdaki ifadeyi oluşturmak çalışıyorum

select * from donors where field is NOT NULL; 

, benim kod şöyle görünür: Eğer documentation görünce

$where = ['field' => NULL]; 
$this->db->get_where('table', $where); 
+2

[Codeigniter Where clause] 'ın olası kopyası (http://stackoverflow.com/questions/10109047/codeigniter-where-clause) – vhu

cevap

29

Sen ile $this->db->where() kullanabilirsiniz Üçüncü parametre, sorgunuzdan kaçmamak için FALSE olarak ayarlandı. Örnek:

$this->db->where('field is NOT NULL', NULL, FALSE); 

Yoksa bu

$where = "field is NOT NULL"; 
$this->db->where($where); 

gibi özel sorgu dizesi kullanabilirsiniz Yani sorgu oluşturucu aşağıdaki gibi görünecektir:

$this->db->select('*'); 
$this->db->where('field is NOT NULL', NULL, FALSE); 
$this->db->get('donors'); 

VEYA

$this->db->select('*'); 
$where = "field is NOT NULL"; 
$this->db->where($where); 
$this->db->get('donors'); 
1

Bunu dene:

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