Thanks John! This looks great. I'll give it a try.

--
Matt


On Wednesday, October 15, 2014 12:35:40 PM UTC-6, John Andersen wrote:
>
> Hi Matt
>
> Created a test setup and got the result you wanted by defining each model 
> as follows:
>
> class LinkedinPerson extends AppModel {
>     public $hasMany = array(
>         'LinkedinRecommendation' => array(
>             'className' => 'LinkedinRecommendation',
>             'foreignKey' => 'linkedin_id',
>         )
>     );
>     public $primaryKey = 'linkedin_id';
>     public $actsAs = array('Containable');
>
> class LinkedinRecommendation extends AppModel {
>     public $hasMany = array(
>         'LinkedinPerson' => array(
>             'className' => 'LinkedinPerson',
>         )
>     );
>     public $actsAs = array('Containable');
>
> In the LinkedinPeople controller I have the index function retrieve all 
> the LinkedinPeople as:
>     public function index() {
>         $this->set('people', $this->LinkedinPerson->find('all', array(
>             'contain' => array('LinkedinRecommendation')
>         )));
>     }
>
> This gives me the following result (debug output):
>
> Array
> (
>     [0] => Array
>         (
>             [LinkedinPerson] => Array
>                 (
>                     [id] => 1
>                     [name] => test person1
>                     [linkedin_id] => 11111111
>                 )
>             [LinkedinRecommendation] => Array
>                 (
>                     [0] => Array
>                         (
>                             [id] => 1
>                             [content] => Recommendation 1
>                             [linkedin_id] => 11111111
>                             [by_linkedin_id] => 44444444
>                         )
>                     [1] => Array
>                         (
>                             [id] => 2
>                             [content] => Recommendation 2
>                             [linkedin_id] => 11111111
>                             [by_linkedin_id] => 22222222
>                         )
>                     [2] => Array
>                         (
>                             [id] => 3
>                             [content] => Recommendation 3
>                             [linkedin_id] => 11111111
>                             [by_linkedin_id] => 22222222
>                         )
>                 )
>         )
>     [1] => Array
>         (
>             [LinkedinPerson] => Array
>                 (
>                     [id] => 2
>                     [name] => test person2
>                     [linkedin_id] => 22222222
>                 )
>             [LinkedinRecommendation] => Array
>                 (
>                     [0] => Array
>                         (
>                             [id] => 4
>                             [content] => Recommendation 4
>                             [linkedin_id] => 22222222
>                             [by_linkedin_id] => 33333333
>                         )
>                     [1] => Array
>                         (
>                             [id] => 7
>                             [content] => Recommendation 7
>                             [linkedin_id] => 22222222
>                             [by_linkedin_id] => 11111111
>                         )
>                 )
>         )
>     [2] => Array
>         (
>             [LinkedinPerson] => Array
>                 (
>                     [id] => 3
>                     [name] => test person3
>                     [linkedin_id] => 33333333
>                 )
>             [LinkedinRecommendation] => Array
>                 (
>                     [0] => Array
>                         (
>                             [id] => 5
>                             [content] => Recommendation 5
>                             [linkedin_id] => 33333333
>                             [by_linkedin_id] => 11111111
>                         )
>                     [1] => Array
>                         (
>                             [id] => 6
>                             [content] => Recommendation 6
>                             [linkedin_id] => 33333333
>                             [by_linkedin_id] => 33333333
>                         )
>                 )
>         )
>     [3] => Array
>         (
>             [LinkedinPerson] => Array
>                 (
>                     [id] => 4
>                     [name] => test person4
>                     [linkedin_id] => 44444444
>                 )
>             [LinkedinRecommendation] => Array
>                 (
>                     [0] => Array
>                         (
>                             [id] => 8
>                             [content] => Recommendation 8
>                             [linkedin_id] => 44444444
>                             [by_linkedin_id] => 11111111
>                         )
>                 )
>         )
> )
>
> Hope you can use the above. Please note that I always uses the Containable 
> behavior.
> Enjoy, John
>
>
>

-- 
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" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to