如何使用CodeIgniter的ActiveRecord选择列值不为空的行?

问题描述:

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

I'm using CodeIgniter's Active Record class to query the MySQL database. I need to select the rows in a table where a field is not set to NULL:

$this->db->where('archived !=', 'NULL');
$q = $this->db->get('projects');

仅返回以下查询:

SELECT * FROM projects WHERE archived != 'NULL';

archived字段是DATE字段.

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

Is there a better way to solve this? I know I can just write the query myself, but I want to stick with the Active Record throughout my code.

where('archived IS NOT NULL', null, false)