I am using scaffolding, so there is no code used there... I have figured this out, though. I needed to define an action to tell the action to find all records and their recursive items. Here is the action I defined:
function index(){ $this->Profile->recursive = 1; $profiles = $this->Profile->find('all'); $this->set('profiles',$profiles); } I then had to make a view for index and used the following code: <table> <thead> <th>Name</th> <th>Address</th> <th>Phone Numbers</th> <th>Emails</th> <th>Actions</th> </thead> <tbody> <?php foreach($profiles as $profile): ?> <tr> <td><?=$profile['Profile']['name']?></td> <td><?=$profile['Profile']['main_address']?></td> <td><?php foreach($profile['Phone'] as $phones){ echo $phones ['phone'].'<br />'; } ?></td> <td> <?php foreach($profile['Email'] as $emails): ?> <a href="mailto:<?=$emails['email']?>"><?=$emails ['email']?></a> <?php endforeach;?> </td> <td></td> </tr> <? endforeach; ?> </tbody> </table> On May 13, 8:12 pm, andy <andy.baugh...@gmail.com> wrote: > Can you post the code you are using to retrieve and display the data? > > On May 12, 3:17 pm, Site Reference <daoustm...@gmail.com> wrote: > > > Hey all, > > > I apologize if this is a bit of a newbie question, but I am having > > trouble getting my database associations to link up...here is what I > > have: > > > MySQL Tables > > > CREATE TABLE phones ( > > id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, > > profile_id INTEGER UNSIGNED NULL, > > phone VARCHAR(255) NULL, > > created INTEGER UNSIGNED NULL, > > modified INTEGER UNSIGNED NULL, > > PRIMARY KEY(id) > > ); > > > CREATE TABLE profiles ( > > id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, > > name VARCHAR(255) NULL, > > main_address VARCHAR(255) NULL, > > created INTEGER UNSIGNED NULL, > > modified INTEGER UNSIGNED NULL, > > PRIMARY KEY(id) > > ); > > > Here are my models: > > > <?php > > class Phone extends AppModel { > > var $name = 'Phone'; > > var $belongsTo = 'Profile';} > > > ?> > > > <?php > > class Profile extends AppModel { > > var $name = 'Profile'; > > var $hasMany = 'Phone';} > > > ?> > > > I am using scaffolding for the controllers. Cake seems to see the > > relationship, but is not listing phones in the profiles. Is there > > anyway that I can do this, or is the fact that there are many phone > > numbers to a profile a problem? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---