I have used join query which joins three tables employee, places and employee_places.The join query gives me all the results as I have used find('all').But in the view page I just want to show employee name from employee table - place name from place table in a dropdown. e.g:- emp1-place1,emp2-place2 and so on. Where should I give the fields name in find. Look at the following code :
$options['joins'] = array( array('table' => 'employees', 'alias' => 'emp', 'type' => 'inner', 'conditions' => array( 'emp.id = EmployeePlace.employee_id ' ) ), array('table' => 'places', 'alias' => 'pl', 'type' => 'inner', 'conditions' => array( 'pl.id = EmployeePlace.place_id' ) ) );
$empTables = $this->Bill->EmployeePlace->find('all', $options);
$this->set(compact('empTables'));
The above query results the following array:-
Array ( [0] => Array ( [EmployeePlace] => Array ( [id] => 1 [employee_id] => 1 [place_id] => 1 [Date] => 2011-02-02 )
[Employee] => Array
(
[id] => 1
[image] =>
[firstName] => Andy
[lastName] => Murray
[date_of_joining] => 2010-09-02
[date_of_leaving] => 2011-02-02
[date_of_birth] => 1991-08-10
[gender] => Male
[supervisor] => 0
[designation] => Manager
[user_id] => 0
)
[Place] => Array
(
[id] => 1
[placeName] => table-1
[section_id] => 1
[position] => Left
[seating_capacity] => 4
)
)
)
I just want firstName from employee - placeName from place table in the dropdown. How do I do this using condition in find.