If you just want to fetch and display the name then you can use
'containable' which allows you to specify exactly which models you
want to fetch data from.
Add var $actsAs = array('Containable'); to /app/app_model.php (as you
pogress with cake you are likely to need this behaviour in all models)
then you can do more instructive finds like this:
$this->data = $this->Referral->find('first', array(
'conditions' => array('Referral.id'=>$id),
'contain' => array(
'AgencyContact' => array(
'Person'=>array
('OnlineAddress','PostalAddress','TelephonyNumber'),
'Agency'=>array('Organisation'=>array
('OnlineAddress','PostalAddress','TelephonyNumber'))
),
'Bednight' => array('Household'=>array('Organisation')),
'Client' => array(
'Person'=>array('Ethnicity','Gender','Religion','Sexuality')
),
'Reason',
'Scheme' => array('Organisation'),
'Staff' => array('Person')
)
)
);
Your find would be something more simple like:
$this->data = $this->Instruments->find('all', array(
'contain' => array(
'Group' => array('Person')
)
)
);
Once you run a find using containable I advise you echo the resulting
array to get used to the different format. Also containable does a
lot of seperate queries rather than one big query so it can limit
things like conditions on the Group or Sector table (I tend to only
use it for view type actions)
If you need to add conditions on the related tables (Group or Sector)
then you will need to force a join. See the below for more
information:
http://groups.google.com/group/cake-php/browse_thread/thread/7f5fceea80bce1b7/dc67e0487ec39a59?hl=en#dc67e0487ec39a59
Paul.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---