Skip to content

FamilyTree::getFamily

James Cobban edited this page Mar 9, 2021 · 2 revisions

$tree->getFamily($idmr)

Up: class FamilyTree

This is a factory method to get an instance of class Family. It takes one parameter:

parameter description
$idmr the value of unique numeric key 'idmr'

This returns a shared instance of class Family which is identified by the value of 'idmr'. This differs from new Family(array('idmr' => $idmr)) in that if the current application process has previously created an instance of class Family for that value of 'idmr' by calling $tree->getFamily($idlr) then $tree->getFamily($idlr) returns that existing instance rather than creating a new instance.

This has two advantages:

  1. If the current thread has previously created an instance then this is much faster than creating a new entry, which would, among other things, require reading the record from the database again.
  2. If all parts of the application use $tree->getFamily($idlr) then all parts of the application will be using the same copy of the object and all changes made by any part of the application will be reflected when the instance is saved to the database by any part of the application.

This method invokes the static class function Family::getFamily($idmr).

Next: $tree->getEvent($ider)

Clone this wiki locally