Is bad practice and really should I be shot for approaching with this particular 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;
}

Most likely. I can not say for several, but that appears like it ought to be considerably reduced than simply utilizing a JOIN.

I'd say benchmark it to be certain, but the general rule Time passes by is "if it is possible cleanly within the SQL, the DB engine can most likely get it done much better than I'm able toInch.

In a nutshell, yes this really is bad. For any couple of rows (e.g. 10) this does not make a difference. However, the moment your table ends up having 10 000 rows this means it first needs to fetch 10 000 rows, then loop through each row and merge everything. An easy Participate in this situation is going to be much faster.