Skip to content

Instantly share code, notes, and snippets.

@ziplizard
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save ziplizard/0e22eb0202e81cded8aa to your computer and use it in GitHub Desktop.

Select an option

Save ziplizard/0e22eb0202e81cded8aa to your computer and use it in GitHub Desktop.

Revisions

  1. ziplizard revised this gist Oct 13, 2014. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -16,4 +16,11 @@
    'foreignKey' => false,
    'conditions' => array('LinkedinPerson.linkedin_id = LinkedinRecommendation.linkedin_id'),
    ),
    );
    );

    // the find
    $res = $this->LinkedinPerson->find('first', array('contain'=>array('LinkedinRecommendation'), 'conditions'=>array('LinkedinPerson.id'=>35)));

    // have also tried
    $res = $this->Person->find('first', array('contain'=>array('LinkedinPerson.LinkedinRecommendation'), 'conditions'=>array('LinkedinPerson.id'=>35)));
    // but get error on relationship of LinkedinPerson to LinkedinRecommendation
  2. ziplizard created this gist Oct 13, 2014.
    19 changes: 19 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    <?php

    // in LinkedinPerson
    public $hasMany = array(
    'LinkedinRecommendation' => array(
    'className' => 'LinkedinRecommendation',
    'foreignKey' => false,
    'dependent' => true,
    ),
    )

    // in LinkedinRecommendation
    public $belongsTo = array(
    'LinkedinPerson' => array(
    'className' => 'LinkedinPerson',
    'foreignKey' => false,
    'conditions' => array('LinkedinPerson.linkedin_id = LinkedinRecommendation.linkedin_id'),
    ),
    );