/** * Creates a link to another instance or extension of AmortizeObject. * This means that a relational table is created between this object's table and the * table of the object to be linked to, and an entry is placed in the relational table linking * the two objects. From this point on, the adopted object can be retrieved as part of a list * by using the method getLinks(). * * Example:\n * $fam = new Family("Smiths");\n * $joe = new Person("Joe");\n * $pam = new Person("Pam");\n * $fam->link($joe); $fam->link($pam);\n * $people = $fam->getLinks("Person"); <--- Returns an array of Pam and Joe Person objects\n */ function link($subject, $relation = NULL) { $this->save(); $subject->save(); $link = new AmortizeLink($this, $subject); return $link->createLink($this->getPrimary(), $subject->getPrimary(), $relation); }