Re: display data 3 tables

2014-06-05 Thread Jeremy Burns : Class Outfit
You are not doing something right. Can you show more code with the debugged output please? Cracking this and understanding what is happening will help you enormously with developing Cake apps from here. On 5 Jun 2014, at 15:18, ajt wrote: > I set recursive to -1 and it doesnt work as I get us

Re: display data 3 tables

2014-06-05 Thread ajt
Yes this works without recursive $contain = array('Teacher' => array('User'),'Student' => array('User')); $this->set('tutor', $this->Tutorsession->find('first',array( 'conditions' => array('Teacher.user_id' => $id), 'contain' => $contain ))); -- Like Us on FaceBook https://w

Re: display data 3 tables

2014-06-05 Thread ajt
I set recursive to -1 and it doesnt work as I get user error again. Recursive set to 2 is what works -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" gro

Re: display data 3 tables

2014-06-05 Thread Jeremy Burns : Class Outfit
With the Containable behaviour you should set recursive to -1. Recursion makes the model automatically attache related models n deep (where n is your recursion level) so can give unexpected (or at least uncontrolled) results. When it is -1 it only returns the model associations you specify. The

Re: display data 3 tables

2014-06-05 Thread ajt
yes thats it, I just didnt know how I referenced it and with this code. This took hours to solve so well done $this->Tutorsession->recursive = 2; $this->Tutorsession->Teacher->contain('User'); $this->set('tutor', $this->Tutorsession->find('first', array(

Re: display data 3 tables

2014-06-05 Thread Jeremy Burns : Class Outfit
Isn't $tutor['Teacher']['User']['username'] what you're looking for? On 5 Jun 2014, at 14:18, ajt wrote: > There just is no user being displayed with the below, there is with Teacher > in the find if I add it but every field is undefined in the view. > > $this->Tutorsession->recursive = 2;

Re: display data 3 tables

2014-06-05 Thread ajt
There just is no user being displayed with the below, there is with Teacher in the find if I add it but every field is undefined in the view. $this->Tutorsession->recursive = 2; $contain = array('Teacher' => array('User')); $this->set('tutor', $this->Tutorsession->find('first',array

Re: display data 3 tables

2014-06-04 Thread Jeremy Burns : Class Outfit
You are referencing the $user variable when you have set a $tutor variable. Add this to your view so you can inspect the shape of the $tutor variable and work out how to access the key you are looking for: die(debug($tutor)); It'll probably look something like this: array( 'Tutorsessio

Re: display data 3 tables

2014-06-04 Thread ajt
This still doesnt work as I get an error when I reference the user table which should be linked unless I need to do this another way? view echo ''. $item['User']['username'].''; ///error user undefined $this->set( 'tutor', $this->Tutorsession->find( 'first', array( 'conditions' => array('T

Re: display data 3 tables

2014-06-04 Thread Jeremy Burns : Class Outfit
A couple of things... Why find all when presumably there is only one expected teacher? The contain statement doesn't go inside an array: $this->set( 'tutor', $this->Tutorsession->find( 'first', array( 'conditions' => array('

Re: display data 3 tables

2014-06-04 Thread ajt
This doesnt work as I get an error when displaying the username from the associated table. I guess i am doing something wrong still. $this->set('tutor', $this->Tutorsession->find('all', array('conditions' => array('Teacher.user_id' => $id) ,array('contain

Re: display data 3 tables

2014-06-04 Thread Jeremy Burns : Class Outfit
Look at the Containable behaviour: http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html On 4 Jun 2014, at 14:47, ajt wrote: > Hi, > > I just want to display fields from 3 tables which I have checked on how to do > this and I am not clear on this. Examples I have found conc

display data 3 tables

2014-06-04 Thread ajt
Hi, I just want to display fields from 3 tables which I have checked on how to do this and I am not clear on this. Examples I have found concentrate on 2 fields or keyed in conditions on multiple tables. I have models all related in some way. I want the username from a tutorsession table and the