jholcomb Posted November 9, 2011 Share Posted November 9, 2011 The issue I have is probably a simple one but I am just not getting it and can't find anything on the web to help me. What I have is 3 tables, Table1(PotentialLoan) is related to Table2(SalesPerson) and Table2 is related to Table3(Dealer). Table1 is not related directly to Table3. What I am trying to do is fill out a form, submit it and then create a print page from the data just entered. My print page requires information from Table3 based on the association with Table2. PotentialLoans has a field named sales_person_id linking it to the SalesPeople table I then have a field named dealer_id in the SalesPeople table linking it to the Dealers table I am looking for the best way to get the dealer information based on the salesperson id in order to show in my view The latest attempt looks like this public function reply($id = null) { $this->PotentialLoan->id = $id; if (!$this->PotentialLoan->exists()) { throw new NotFoundException(__('Invalid potential loan')); } $this->set('potentialLoan', $this->PotentialLoan->read(null, $id)); $this->set('dealer', $this->PotentialLoan->SalesPerson->Dealer->find('first', $id)); } This appears to work until you look closer and realize that you are not getting the correct dealer information. All the associations are set up correctly in the models. Quote Link to comment https://forums.phpfreaks.com/topic/250802-including-indirectly-related-table-data-using-cakephp/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.