I want to retrieve values of the below field names only if they are not null.This is code I have written in the model. Its easy to check only one field which is not null. But how can I check that for multiple fields. Its really great if someone can help me. Thanks in advance.
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();
}
You can chain methods in codeigniter so you add this
$this->db->where('mycolumn1 !=', NULL);
$this->db->where('mycolumn2 !=', NULL);
Try this:
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();
}