Php 如何从ci中不为空的多个字段中检索数据

Php 如何从ci中不为空的多个字段中检索数据,php,codeigniter,activerecord,Php,Codeigniter,Activerecord,我只想在以下字段名不为空时检索它们的值。这是我在模型中编写的代码。只需检查一个非空字段即可。但是我如何检查多个字段的值呢。如果有人能帮助我,那真是太好了。提前谢谢 function viewSummary($rid){ $this->db->select('summary_call1,summary_call1_date,summary_call2,summary_call2_date,summary_sms1,summary_sms1_date,summary_sms2

我只想在以下字段名不为空时检索它们的值。这是我在模型中编写的代码。只需检查一个非空字段即可。但是我如何检查多个字段的值呢。如果有人能帮助我,那真是太好了。提前谢谢

 function viewSummary($rid){

    $this->db->select('summary_call1,summary_call1_date,summary_call2,summary_call2_date,summary_sms1,summary_sms1_date,summary_sms2,summary_sms2_date,summary_email1,summary_email1_date,summary_email2,summary_email2_date,summary_other1,summary_other1_date');
    $query = $this->db->get_where('register',array('r_id'=>$rid));

    return $query->result();
}

您可以在codeigniter中链接方法,以便添加此

$this->db->where('mycolumn1 !=', NULL);
$this->db->where('mycolumn2 !=', NULL);
试试这个:

function viewSummary($rid) {
    $this->db->select('summary_call1,summary_call1_date,summary_call2,summary_call2_date,summary_sms1,summary_sms1_date,summary_sms2,summary_sms2_date,summary_email1,summary_email1_date,summary_email2,summary_email2_date,summary_other1,summary_other1_date');

    $this->db->where('summary_call1 IS NOT NULL', null, false);
    $this->db->where('summary_call2 IS NOT NULL', null, false);
    //etc
    $query = $this->db->get_where('register',array('r_id'=>$rid));

    return $query->result();
}