I am using CodeIgniter
I have two tables -
Company int id , varchar name
Employee int id, varchar name , int company_id
I have a simple controller called Employees Controller
<?php
class Employees extends CI_Controller {
public function index()
{
----
----
$data['employees'] = $selected_employees;
$this->load->view('employees/index',$data);
}
}
This controller passes an array of Employees to the view . So inside my view , I can freely use employees[4].name , employees[3].id etc
Now If I want to show the name of the Company of the employees , it seems the only way is the Controller should pass another array with the name of the companies to the view . Is there any better way to achieve this - so that the controller doesnt have to explicitly have to send the data ?
For eg - say I want to access employees[4].company.name I have been spoilt by Rails . I used to take these for granted .