Argomento non valido fornito per foreach ()

Se non ho record nella mia tabella di database, ricevo un errore Argomento non valido fornito foreach () puoi aiutarmi a risolvere questo errore.

codice del controller

$data['cc'] = $this->Profile_model->supplier_companydetails(); $this->load->view('suppliercompany', $data); 

Codice modello

 public function supplier_companydetails() { $this->db->select('*'); $this->db->from('supplier_otherdetails'); $this->db->where('supplierid_fk', $this->session->id); $query = $this->db->get(); //return $query->result(); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { //add all data to session $newdataaa = array( 'company_name' => $row->company_name, 'company_estd_date' => $row->company_estd_date, 'tin_number' => $row->tin_number, 'company_address' => $row->company_address, 'area' => $row->area, 'city' => $row->city, 'state' => $row->state, 'country' => $row->country, ); } $this->session->set_userdata($newdataaa); return $query->result(); } } 

Basta modificare questa linea

 foreach ($query->result() as $row) { 

A

foreach ((array) $ query-> result () come $ row) {