I want to get a list of email addresses from the database, what I have tried are here:
In my model:
public function get_email_address_by_sector($search_by, $search_field)
{
$this->db->select('*');
$this->db->like($search_by, $search_field);
$query = $this->db->get('tb_company');
$row = $query->row_array();
return $row['email'];
}
I want to see the data in the array with this controller:
public function get_email_address($search_by, $search_field)
{
$recipients = $this->company_model->get_email_address_by_sector($search_by, $search_field);
print_r($recipients);
}
What does row_array() return in CodeIgniter?
row_array()returns a flat array representing the first qualifying row of the query. If there were no qualifying rows, thennullis returned. For this reason, it is unstable to try to access theemailelement of a potentiallynullvalue. You will need to null coalesce.