Cakephp: Correct way to resolve hasMany - hasMany relation
Posted
by
Chris
on Stack Overflow
See other posts from Stack Overflow
or by Chris
Published on 2010-12-23T20:11:17Z
Indexed on
2010/12/23
21:54 UTC
Read the original article
Hit count: 386
I have three models:
Company, Car, Passenger
Company hasMany Cars
Car hasMany Passenger
These relations seem to work independetly: Car shows all Passengers and Company shows all Cars.
But I cannot resolve the Company - Passenger (Show all Passengers of a Company).
My controller for Company:
function index(){
//grab all companies and pass it to the view:
$companies = $this->Company->find('all');
$this->set('companies', $companies);
}
This displays all companies with all their respective cars. However the array does not contain an entry for passenger.
What do I have to do to completely resovle the Company - Car - Passenger relation?
© Stack Overflow or respective owner