Is this a bad practice, and is it necessary to shoot for this code?
function get_business_addresses($business_id) { $query = $this->db->get_where('contact_business_addr_rel', array('business_id'=> $business_id)); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $address_id = $row->address_id; $address_type_id = $row->address_type_id; $this->db->select('type'); $q = $this->db->get_where('contact_business_address_type',array('id'=> $address_type_id)); $query = $this->db->get_where('contact_business_addresses',array('id'=> $address_id)); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $row2 = $q->row(); $obj_merged = (object) array_merge((array) $row, (array) $row2); $data[] = $obj_merged; } } } } return $data; }
source share