当前位置: 首页>>代码示例>>PHP>>正文


PHP Person::GetDatabase方法代码示例

本文整理汇总了PHP中Person::GetDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::GetDatabase方法的具体用法?PHP Person::GetDatabase怎么用?PHP Person::GetDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Person的用法示例。


在下文中一共展示了Person::GetDatabase方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Run

 /**
  * Main DataGen Runner
  * @return void
  */
 public static function Run()
 {
     // Run "Fake Data" SQL Script
     $strFakeDataSql = file_get_contents(__DOCROOT__ . '/../database/fake_data.sql');
     foreach (explode("\n", $strFakeDataSql) as $strSql) {
         $strSql = trim($strSql);
         if (strlen($strSql) && substr($strSql, 0, 1) != '#') {
             Person::GetDatabase()->NonQuery($strSql);
         }
     }
     self::$SystemStartDate = new QDateTime('1990-01-01');
     self::$LifeStartDate = new QDateTime('1930-01-01');
     self::$OldestChildBirthDate = QDateTime::Now(false);
     self::$OldestChildBirthDate->Year -= 18;
     // Get Cached Data
     self::$CommentCategoryArray = CommentCategory::LoadAll();
     // Erase Directories
     exec('rm -r -f ' . __DOCROOT__ . '/../file_assets/head_shots');
     exec('rm -r -f ' . __DOCROOT__ . '/../file_assets/contribution_images');
     // Generate Stuff
     ChmsDataGen::GenerateMinistries();
     ChmsDataGen::GenerateUsers();
     ChmsDataGen::GenerateHouseholds();
     ChmsDataGen::GenerateStewardship();
     self::$MaxPersonId = Person::CountAll();
     ChmsDataGen::GenerateCommunicationLists();
     ChmsDataGen::GenerateGroups();
 }
开发者ID:alcf,项目名称:chms,代码行数:32,代码来源:datagen.cli.php

示例2: MergeWith

 /**
  * Merges two records together.
  * @param Person $objPersonMergeWith
  * @param boolean $blnUseThisDetails boolean on whether to use this person's Person object details, or if false, use the PersonMergeWith's
  */
 public function MergeWith(Person $objPersonMergeWith, $blnUseThisDetails)
 {
     QLog::Log(sprintf('Merging %s (ID %s) with %s (ID %s) - %s', $this->Name, $this->Id, $objPersonMergeWith->Name, $objPersonMergeWith->Id, $blnUseThisDetails ? 'left' : 'right'));
     Person::GetDatabase()->TransactionBegin();
     // Household Participation Records
     if ($this->HouseholdAsHead && $objPersonMergeWith->HouseholdAsHead) {
         $this->HouseholdAsHead->MergeHousehold($objPersonMergeWith->HouseholdAsHead, $this);
     } else {
         if ($this->HouseholdAsHead) {
             // Go through each MergeWith HouseholdParticipation -- Throw if it's another household, Delete if it's this Household-as-Head
             foreach ($objPersonMergeWith->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
                 if ($objHouseholdParticipation->HouseholdId != $this->HouseholdAsHead->Id) {
                     throw new QCallerException('Cannot merge this head of household with a person record that exists in other households');
                 } else {
                     $objHouseholdParticipation->Delete();
                 }
             }
         } else {
             if ($objHousehold = $objPersonMergeWith->HouseholdAsHead) {
                 // Go through each of this's HouseholdParticipation -- Throw if it's another household, Delete if it's MergeWith's Household-as-Head
                 foreach ($this->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
                     if ($objHouseholdParticipation->HouseholdId != $objPersonMergeWith->HouseholdAsHead->Id) {
                         throw new QCallerException('Cannot merge MergeWith head of household with this person record which exists in other households');
                     } else {
                         $objHouseholdParticipation->Delete();
                     }
                 }
                 $objHousehold->HeadPerson = $this;
                 $objHousehold->Save();
                 $objParticipation = HouseholdParticipation::LoadByPersonIdHouseholdId($objPersonMergeWith->Id, $objHousehold->Id);
                 $objParticipation->PersonId = $this->Id;
                 $objParticipation->Save();
             } else {
                 // Otherwise: members of multiple households! but head of none
                 foreach ($objPersonMergeWith->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
                     if (HouseholdParticipation::LoadByPersonIdHouseholdId($this->Id, $objHouseholdParticipation->HouseholdId)) {
                         $objHouseholdParticipation->Delete();
                     } else {
                         $objHouseholdParticipation->PersonId = $this->Id;
                         $objHouseholdParticipation->Save();
                     }
                 }
             }
         }
     }
     if (!$blnUseThisDetails) {
         $this->FirstName = $objPersonMergeWith->FirstName;
         $this->MiddleName = $objPersonMergeWith->MiddleName;
         $this->LastName = $objPersonMergeWith->LastName;
         $this->MailingLabel = $objPersonMergeWith->MailingLabel;
         $this->PriorLastNames = $objPersonMergeWith->PriorLastNames;
         $this->Nickname = $objPersonMergeWith->Nickname;
         $this->Title = $objPersonMergeWith->Title;
         $this->Suffix = $objPersonMergeWith->Suffix;
         $this->Gender = $objPersonMergeWith->Gender;
         $this->DateOfBirth = $objPersonMergeWith->DateOfBirth;
         $this->DobYearApproximateFlag = $objPersonMergeWith->DobYearApproximateFlag;
         $this->DobGuessedFlag = $objPersonMergeWith->DobGuessedFlag;
         $this->Age = $objPersonMergeWith->Age;
         $this->DeceasedFlag = $objPersonMergeWith->DeceasedFlag;
         $this->DateDeceased = $objPersonMergeWith->DateDeceased;
     }
     // Attributes
     foreach ($objPersonMergeWith->GetAttributeValueArray() as $objAttributeValue) {
         // Check for double-defined attributes
         if ($objDoubleDefinedAttribute = AttributeValue::LoadByAttributeIdPersonId($objAttributeValue->AttributeId, $this->Id)) {
             if ($blnUseThisDetails) {
                 $objAttributeValue->Delete();
             } else {
                 $objDoubleDefinedAttribute->Delete();
                 $objAttributeValue->PersonId = $this->Id;
                 $objAttributeValue->Save();
             }
             // Nothing double-defined -- just move it over!
         } else {
             $objAttributeValue->PersonId = $this->Id;
             $objAttributeValue->Save();
         }
     }
     // Comments
     foreach ($objPersonMergeWith->GetCommentArray() as $objComment) {
         $objComment->PersonId = $this->Id;
         $objComment->Save();
     }
     // Memberships
     foreach ($objPersonMergeWith->GetMembershipArray() as $objMembership) {
         $objMembership->PersonId = $this->Id;
         $objMembership->Save();
     }
     // Communication Lists
     foreach ($objPersonMergeWith->GetCommunicationListArray() as $objCommList) {
         $objPersonMergeWith->UnassociateCommunicationList($objCommList);
         if (!$this->IsCommunicationListAssociated($objCommList)) {
             $this->AssociateCommunicationList($objCommList);
         }
//.........这里部分代码省略.........
开发者ID:alcf,项目名称:chms,代码行数:101,代码来源:Person.class.php

示例3: dtgCustom_Bind

    protected function dtgCustom_Bind()
    {
        //Set up our normal query
        $sql = 'SELECT
					p.first_name as "FirstName",
					p.last_name as "LastName",
					count(a.id) as "AddressCount"
				FROM person as p
					LEFT JOIN address as a on a.person_id = p.id
				GROUP BY p.id';
        //apply any filters the user has set
        foreach ($this->dtgCustom->FilterInfo as $filter) {
            if ($filter['column'] == 'AddressCount') {
                $sql .= ' HAVING count(a.id) = ' . $filter['value'];
            }
        }
        //and run the query, using it as the datasource for the grid
        $objDatabase = Person::GetDatabase();
        $objDbResult = $objDatabase->Query($sql);
        $array = array();
        while ($mixRow = $objDbResult->FetchArray()) {
            $array[] = $mixRow;
        }
        $this->dtgCustom->DataSource = $array;
    }
开发者ID:tomVertuoz,项目名称:framework,代码行数:25,代码来源:advanced_filtering.php

示例4: UnassociateAllNameItems

    /**
     * Unassociates all NameItems
     * @return void
     */
    public function UnassociateAllNameItems()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllNameItemArray on this unsaved Person.');
        }
        // Get the Database Object for this Class
        $objDatabase = Person::GetDatabase();
        // Journaling (if applicable)
        if ($objDatabase->JournalingDatabase) {
            $objResult = $objDatabase->Query('SELECT `name_item_id` AS associated_id FROM `person_nameitem_assn` WHERE `person_id` = ' . $objDatabase->SqlVariable($this->intId));
            while ($objRow = $objResult->GetNextRow()) {
                $this->JournalNameItemAssociation($objRow->GetColumn('associated_id'), 'DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`person_nameitem_assn`
				WHERE
					`person_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
开发者ID:alcf,项目名称:chms,代码行数:26,代码来源:PersonGen.class.php

示例5: testTransactionWithCacheDeleteRollBack2

 public function testTransactionWithCacheDeleteRollBack2()
 {
     Person::GetDatabase()->Caching = true;
     // establish a cache object we can work with
     $objCacheProvider = QApplication::$objCacheProvider;
     QApplication::$objCacheProvider = new QCacheProviderLocalMemoryTest(array());
     // cache is empty now
     // create an object in the database
     $objPerson1z = new Person();
     $objPerson1z->FirstName = "test";
     $objPerson1z->LastName = "test";
     $objPerson1z->Save();
     Person::Load($objPerson1z->Id);
     // the person object is placed in a cache
     $this->assertEqual(count(QApplication::$objCacheProvider->arrLocalCache), 1, "Object is placed in a cache.");
     try {
         Person::GetDatabase()->TransactionBegin();
         // cache is substituted
         $objPerson1 = Person::Load($objPerson1z->Id);
         // person object is placed in the temporary cache
         $objPerson1->Delete();
         // person object is removed from the temporary cache
         throw new Exception("DATABASE ERROR!");
         // imitate the database error in the next Save call
         Person::GetDatabase()->TransactionCommit();
     } catch (Exception $ex) {
         Person::GetDatabase()->TransactionRollBack();
         // actual cache leaved unchanged
     }
     $this->assertEqual(count(QApplication::$objCacheProvider->arrLocalCache), 1, "Object is NOT removed from a cache after delete because of the transaction roll back.");
     // restore the actual cache object
     QApplication::$objCacheProvider = $objCacheProvider;
     // clean up
     $objPerson1 = Person::Load($objPerson1z->Id);
     // person object is placed in the temporary cache
     $objPerson1->Delete();
 }
开发者ID:tomVertuoz,项目名称:framework,代码行数:37,代码来源:QDatabaseTests.php

示例6: QDateTime

    $objPerson->DisplayRealNameFlag = $objRow['display_real_name_flag'];
    $objPerson->DisplayEmailFlag = $objRow['display_email_flag'];
    $objPerson->OptInFlag = $objRow['opt_in_flag'];
    $objPerson->DonatedFlag = $objRow['donated_flag'];
    $objPerson->Location = $objRow['location'];
    $objPerson->Url = $objRow['url'];
    $objPerson->RegistrationDate = new QDateTime($objRow['registration_date']);
    if ($objRow['country_id']) {
        $objCountryResult = $objDb->query('SELECT * FROM country WHERE id=' . $objRow['country_id']);
        $objCountryRow = $objCountryResult->fetch_array();
        $objPerson->Country = Country::LoadByCode($objCountryRow['code']);
    }
    $objPerson->RefreshDisplayName();
    $objPerson->Save();
    if ($objPerson->Id != $objRow['id']) {
        Person::GetDatabase()->NonQuery('UPDATE person SET id=' . $objRow['id'] . ' WHERE id=' . $objPerson->Id);
    }
}
$intNewTopicLinkIdArray[3591] = 7;
$intNewTopicLinkIdArray[3578] = 7;
$intNewTopicLinkIdArray[3547] = 7;
$intNewTopicLinkIdArray[3455] = 7;
$intNewTopicLinkIdArray[3242] = 7;
$intNewTopicLinkIdArray[3244] = 7;
$objResult = $objDb->query('SELECT * FROM topic ORDER BY id');
while (QDataGen::DisplayWhileTask('Migrating Topics', $objResult->num_rows)) {
    $objRow = $objResult->fetch_array();
    $objTopic = new Topic();
    if (array_key_exists(intval($objRow['id']), $intNewTopicLinkIdArray)) {
        $objTopic->TopicLinkId = $intNewTopicLinkIdArray[intval($objRow['id'])];
    } else {
开发者ID:qcodo,项目名称:qcodo-website,代码行数:31,代码来源:migrator.cli.php

示例7: Truncate

    /**
     * Truncate person table
     * @return void
     */
    public static function Truncate()
    {
        // Get the Database Object for this Class
        $objDatabase = Person::GetDatabase();
        // Perform the Query
        $objDatabase->NonQuery('
				TRUNCATE `person`');
    }
开发者ID:qcodo,项目名称:qcodo-api,代码行数:12,代码来源:PersonGen.class.php

示例8: UnassociateAllTopicsAsRead

    /**
     * Unassociates all TopicsAsRead
     * @return void
     */
    public function UnassociateAllTopicsAsRead()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllTopicAsReadArray on this unsaved Person.');
        }
        // Get the Database Object for this Class
        $objDatabase = Person::GetDatabase();
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`read_topic_person_assn`
				WHERE
					`person_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
开发者ID:klucznik,项目名称:qcodo-website,代码行数:19,代码来源:PersonGen.class.php

示例9: Reconcile


//.........这里部分代码省略.........
             $objMatchedPersonArray = array();
             foreach ($objPersonArray as $objPerson) {
                 if ($objPerson->IsNameAndAddressMatch($this->FirstName, $this->LastName, $objHomeAddress, $objMailingAddress)) {
                     $objMatchedPersonArray[] = $objPerson;
                 }
             }
             if (count($objMatchedPersonArray) == 1) {
                 $objPerson = $objMatchedPersonArray[0];
             } else {
                 if (!count($objMatchedPersonArray)) {
                     $objPerson = null;
                 } else {
                     $objPerson = $objMatchedPersonArray[0];
                     $intCurrentScore = 0;
                     foreach ($objMatchedPersonArray as $objMatchedPerson) {
                         $intScore = $objMatchedPerson->ScoreDobGenderMobileMatch($dttDateOfBirth, $strGenderFlag, $strMobilePhone);
                         if ($intScore > $intCurrentScore) {
                             $intCurrentScore = $intScore;
                             $objPerson = $objMatchedPerson;
                         }
                     }
                 }
             }
         }
     }
     // If we have a person, make sure it's not already linked
     if ($objPerson) {
         if ($objPerson->PublicLogin) {
             return $objPerson;
         }
     }
     // We now have either a unlinked Person record or no person record
     // Let's make all the DB updates we need to
     Person::GetDatabase()->TransactionBegin();
     // Do we have a single Person object?
     // If not, let's create it
     if (!$objPerson) {
         $blnMaleFlag = null;
         if ($strGenderFlag = trim(strtoupper($strGenderFlag))) {
             $blnMaleFlag = $strGenderFlag == 'M';
         }
         $intPhoneTypeId = $strMobilePhone ? PhoneType::Mobile : null;
         $objPerson = Person::CreatePerson($this->FirstName, null, $this->LastName, $blnMaleFlag, $this->EmailAddress, $strMobilePhone, $intPhoneTypeId);
         $objPerson->DateOfBirth = $dttDateOfBirth;
         if ($objPerson->DateOfBirth) {
             $objPerson->DobGuessedFlag = false;
             $objPerson->DobYearApproximateFlag = false;
         }
         $objPerson->PublicCreationFlag = true;
         $objPerson->Save();
     }
     //////////////////////////////////
     // Let's update the information
     //////////////////////////////////
     // Email Address
     $objPerson->ChangePrimaryEmailTo($this->EmailAddress, false);
     // Gender and DOB
     if ($strGenderFlag = trim(strtoupper($strGenderFlag))) {
         $objPerson->Gender = $strGenderFlag;
     }
     if ($dttDateOfBirth) {
         $objPerson->DateOfBirth = $dttDateOfBirth;
         $objPerson->DobGuessedFlag = false;
         $objPerson->DobYearApproximateFlag = false;
     }
     // Mobile Phone
开发者ID:alcf,项目名称:chms,代码行数:67,代码来源:ProvisionalPublicLogin.class.php


注:本文中的Person::GetDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。