On Sep 12, 2006, at 11:40 AM, Tony wrote:

>
> John and AD7six,
>
> Did I do this correctly?
>
> class Level extends AppModel
> {
>    var $name = "Level";
>    var $hasMany = array('Role1' =>
>                          array('className'   => 'Role',
>                                'conditions'       => '',
>                                'order'              => '',
>                                'limit'               => '',
>                                'foreignKey'      => 'role1_id',
>                                'dependent'      => false,
>                                'exclusive'       => false
>                                'finderSql'   => ''
>                          ),
>                          'Role2' =>
>                          array('className'   => 'Role',
>                                'conditions'      => '',
>                                'order'              => '',
>                                'limit'               => '',
>                                'foreignKey'     => 'role1_id',
>                                'dependent'     => false,
>                                'exclusive'      => false
>                                'finderSql'       => ''
>                          )
>    );
> }

You have both the keys named the same (role1_id and role1_id), but  
otherwise it looks okay.

> I hope that's right LOL! If I have this correct how would I pull in  
> the
> data. Would I do something like $this->Level->read(null, '44');

To get recursive model data, use find(), not read(), but yeah–that's  
the basic idea.

> Then how would I access the titles field in the roles database when  
> I'm
> outputting into the view.

First, assign your Level data to the view:

$this->set('level', $this->Level->findById(44));

And in the view, you should have access to role data:

<?php echo $level['Role1']['id']; ?>

> You guys are helping me out so much I totally appreciate all the help.

Hope that works for you.

-- John
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to