本文整理汇总了PHP中Relationship::LoadByPersonIdRelatedToPersonId方法的典型用法代码示例。如果您正苦于以下问题:PHP Relationship::LoadByPersonIdRelatedToPersonId方法的具体用法?PHP Relationship::LoadByPersonIdRelatedToPersonId怎么用?PHP Relationship::LoadByPersonIdRelatedToPersonId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relationship
的用法示例。
在下文中一共展示了Relationship::LoadByPersonIdRelatedToPersonId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UpdateLinkedRelationship
/**
* Given this relationship record, this will update the "linked" relationship record with the same stats and details.
*
* This will CREATE the Linked Relationship record if none yet exists.
*
*/
public function UpdateLinkedRelationship()
{
$objPerson = $this->Person;
$objRelatedPerson = $this->RelatedToPerson;
$objLinkedRelationship = Relationship::LoadByPersonIdRelatedToPersonId($objRelatedPerson->Id, $objPerson->Id);
if (!$objLinkedRelationship) {
$objLinkedRelationship = new Relationship();
$objLinkedRelationship->Person = $objRelatedPerson;
$objLinkedRelationship->RelatedToPerson = $objPerson;
}
// Figure out the "Opposite" relationship to create
switch ($this->intRelationshipTypeId) {
case RelationshipType::Child:
$objLinkedRelationship->RelationshipTypeId = RelationshipType::Parental;
break;
case RelationshipType::Parental:
$objLinkedRelationship->RelationshipTypeId = RelationshipType::Child;
break;
case RelationshipType::Sibling:
$objLinkedRelationship->RelationshipTypeId = RelationshipType::Sibling;
break;
case RelationshipType::Grandchild:
$objLinkedRelationship->RelationshipTypeId = RelationshipType::Grandparent;
break;
case RelationshipType::Grandparent:
$objLinkedRelationship->RelationshipTypeId = RelationshipType::Grandchild;
break;
default:
throw new Exception('Invalid Relationship Type Id: ' . $intRelationshipTypeId);
}
$objLinkedRelationship->Save();
}
示例2: RefreshRole
/**
* Calculates the role value based on the person and his/her relationship to the head of household.
* Will call save unless explicitly specified not to
* @param boolean $blnSave whether or not to call save after updating role value
* @return void
*/
public function RefreshRole($blnSave = true)
{
$objHeadPerson = $this->Household->HeadPerson;
if ($this->PersonId == $objHeadPerson->Id) {
$this->strRole = 'Head';
if ($blnSave) {
$this->Save();
}
return;
}
// Calculate based on family relationships
// Married?
if (($objMarriage = $this->Person->GetMostRecentMarriage()) && $objMarriage->MarriageStatusTypeId == MarriageStatusType::Married && $objMarriage->MarriedToPersonId == $objHeadPerson->Id) {
switch ($this->Person->Gender) {
case 'M':
$this->strRole = 'Husband';
break;
case 'F':
$this->strRole = 'Wife';
break;
default:
$this->strRole = 'Spouse';
break;
}
if ($blnSave) {
$this->Save();
}
return;
}
if ($objRelationship = Relationship::LoadByPersonIdRelatedToPersonId($objHeadPerson->Id, $this->Person->Id)) {
$this->strRole = $objRelationship->Relation;
if ($blnSave) {
$this->Save();
}
return;
}
// Can't figure out any relationship -- simply specify as "Child" or "Adult"
if ($this->Person->IsChild()) {
$this->strRole = 'Child';
} else {
$this->strRole = 'Adult';
}
if ($blnSave) {
$this->Save();
}
return;
}
示例3:
case 'daughter':
$intRelationshipTypeId = RelationshipType::Child;
break;
case 'brother':
case 'sister':
$intRelationshipTypeId = RelationshipType::Sibling;
break;
case 'grandmother':
case 'grandfather':
$intRelationshipTypeId = RelationshipType::Grandparent;
break;
case 'grandchild':
case 'grandson':
case 'granddaughter':
$intRelationshipTypeId = RelationshipType::Grandchild;
break;
}
if ($intRelationshipTypeId) {
$objPerson = Person::Load($intPersonIdByIndvId[$objRow['indvid']]);
$objRelatedPerson = Person::Load($intPersonIdByIndvId[$objRow['reltindvid']]);
if (!Relationship::LoadByPersonIdRelatedToPersonId($objPerson->Id, $objRelatedPerson->Id)) {
$objPerson->AddRelationship($objRelatedPerson, $intRelationshipTypeId);
}
}
}
}
$objParticipationCursor = HouseholdParticipation::QueryCursor(QQ::All());
$intCount = HouseholdParticipation::CountAll();
while (QDataGen::DisplayWhileTask('Recalculating HouseholdParticipation Roles', $intCount) && ($objHouseholdParticipation = HouseholdParticipation::InstantiateCursor($objParticipationCursor))) {
$objHouseholdParticipation->RefreshRole();
}
示例4: MergeWith
//.........这里部分代码省略.........
$objMembership->PersonId = $this->Id;
$objMembership->Save();
}
// Communication Lists
foreach ($objPersonMergeWith->GetCommunicationListArray() as $objCommList) {
$objPersonMergeWith->UnassociateCommunicationList($objCommList);
if (!$this->IsCommunicationListAssociated($objCommList)) {
$this->AssociateCommunicationList($objCommList);
}
}
// Head Shots
foreach ($objPersonMergeWith->GetHeadShotArray() as $objHeadShot) {
$objHeadShot->PersonId = $this->Id;
$objHeadShot->Save();
}
// Group Participation
foreach ($objPersonMergeWith->GetGroupParticipationArray() as $objGroupParticipation) {
$objGroupParticipation->PersonId = $this->Id;
$objGroupParticipation->Save();
}
// NameItemAssn
$objPersonMergeWith->UnassociateAllNameItems();
// Marrriage Records
foreach ($objPersonMergeWith->GetMarriageArray() as $objMarriage) {
$this->CreateMarriageWith($objMarriage->MarriedToPerson, $objMarriage->DateStart, $objMarriage->DateEnd, $objMarriage->MarriageStatusTypeId);
$objMarriage->DeleteThisAndLinked();
}
foreach ($objPersonMergeWith->GetMarriageAsMarriedToArray() as $objMarriage) {
$this->CreateMarriageWith($objMarriage->Person, $objMarriage->DateStart, $objMarriage->DateEnd, $objMarriage->MarriageStatusTypeId);
$objMarriage->DeleteThisAndLinked();
}
// Family Relationships
foreach ($objPersonMergeWith->GetRelationshipArray() as $objRelationship) {
if (!Relationship::LoadByPersonIdRelatedToPersonId($this->Id, $objRelationship->RelatedToPersonId)) {
$this->AddRelationship($objRelationship->RelatedToPerson, $objRelationship->RelationshipTypeId);
}
$objRelationship->DeleteThisAndLinked();
}
foreach ($objPersonMergeWith->GetRelationshipAsRelatedToArray() as $objRelationship) {
if (!Relationship::LoadByPersonIdRelatedToPersonId($this->Id, $objRelationship->PersonId)) {
$this->AddRelationship($objRelationship->Person, $objRelationship->RelationshipTypeId);
}
$objRelationship->DeleteThisAndLinked();
}
// Phones
foreach ($objPersonMergeWith->GetPhoneArray() as $objContact) {
$objContact->PersonId = $this->Id;
$objContact->Save();
}
// Addresses
foreach ($objPersonMergeWith->GetAddressArray() as $objContact) {
$objContact->PersonId = $this->Id;
$objContact->Save();
}
// Email
foreach ($objPersonMergeWith->GetEmailArray() as $objContact) {
$objContact->PersonId = $this->Id;
$objContact->Save();
}
// Other Contact Info
foreach ($objPersonMergeWith->GetOtherContactInfoArray() as $objContact) {
$objContact->PersonId = $this->Id;
$objContact->Save();
}
// Checking Account Lookups
foreach ($objPersonMergeWith->GetCheckingAccountLookupArray() as $objCheckingAccount) {