相关疑难解决方法(0)

使用CodeIgniter查询MySQL,选择field为NULL的行

我正在使用CodeIgniter的Active Record类来查询MySQL数据库.我需要在表中选择一个字段未设置为NULL的行:

$this->db->where('archived !=', 'NULL');
$q = $this->db->get('projects');
Run Code Online (Sandbox Code Playgroud)

这只返回此查询:

SELECT * FROM projects WHERE archived != 'NULL';
Run Code Online (Sandbox Code Playgroud)

archived字段是一个DATE字段.

有没有更好的方法来解决这个问题?我知道我可以自己编写查询,但我不想在整个代码中坚持使用Active Record.

mysql null activerecord codeigniter

72
推荐指数
5
解决办法
10万
查看次数

codeigniter中的值不是NULL

我正在尝试创建以下语句:

select * from donors where field is NOT NULL;
Run Code Online (Sandbox Code Playgroud)

使用codeigniter,我的代码如下所示:

$where = ['field' => NULL];
$this->db->get_where('table', $where);
Run Code Online (Sandbox Code Playgroud)

mysql codeigniter-3

16
推荐指数
2
解决办法
5万
查看次数

标签 统计

mysql ×2

activerecord ×1

codeigniter ×1

codeigniter-3 ×1

null ×1