Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql codeigniter中的值不为NULL_Mysql_Codeigniter 3 - Fatal编程技术网

Mysql codeigniter中的值不为NULL

Mysql codeigniter中的值不为NULL,mysql,codeigniter-3,Mysql,Codeigniter 3,我试图创建以下语句: select * from donors where field is NOT NULL; 使用codeigniter,我的代码如下所示: $where = ['field' => NULL]; $this->db->get_where('table', $where); $this->db->select('*'); $this->db->where('field is NOT NULL', NULL, FALSE); $th

我试图创建以下语句:

select * from donors where field is NOT NULL;
使用codeigniter,我的代码如下所示:

$where = ['field' => NULL];
$this->db->get_where('table', $where);
$this->db->select('*');
$this->db->where('field is NOT NULL', NULL, FALSE);
$this->db->get('donors');
当您看到时,可以使用
$this->db->where()。
例如:

或者您可以像这样使用自定义查询字符串

$where = "field is  NOT NULL";
$this->db->where($where);
因此,您的查询生成器将如下所示:

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

试试这个:

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

如果您有一些复杂的查询,其中包含多个where和Having条件

请查看以下示例:

$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();
$this->db->select(['id'、'email\u address'、'discard\u at'、'datediff(now()、'discard\u at`)AS daysdiff');
$this->db->having('daysdiff<11');
$query=$this->db->get_-where('forms',array('audd_-form'=>1,'audd_-at!='=>NULL');
返回$query->result();
试试这个:

$this->db->where('columnName !=', null);

可能重复欢迎使用Stackoverflow。请详细说明你的答案是如何工作的,以及它与公认答案的区别。请详细说明你的答案是如何工作的,以及它与公认答案的区别。这对我来说是有效的。在我的例子中,我必须确保“NULL”出现在引号中,如本例中所示:
'about\u at!='=>'空“