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


PHP Person::Save方法代码示例

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


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

示例1: testSaveAndDelete

 public function testSaveAndDelete()
 {
     $objPerson1 = new Person();
     $objPerson1->FirstName = "Test1";
     $objPerson1->LastName = "Last1";
     $objPerson1->Save();
     $items = Person::QueryArray(QQ::AndCondition(QQ::Equal(QQN::Person()->FirstName, "Test1"), QQ::Equal(QQN::Person()->LastName, "Last1")));
     $this->assertEqual(sizeof($items), 1, "Saved the Person object");
     $objPerson2 = $items[0];
     $this->assertEqual($objPerson2->FirstName, "Test1", "The first name is correct");
     $this->assertEqual($objPerson2->LastName, "Last1", "The last name is correct");
     $objPerson2->Delete();
     $items = Person::QueryArray(QQ::AndCondition(QQ::Equal(QQN::Person()->FirstName, "Test1"), QQ::Equal(QQN::Person()->LastName, "Last1")));
     $this->assertEqual(sizeof($items), 0, "Deleting the Person object");
 }
开发者ID:tomVertuoz,项目名称:framework,代码行数:15,代码来源:BasicOrmTests.php

示例2: Form_Create

 protected function Form_Create()
 {
     $count = 10000;
     Project::ClearCache();
     Person::ClearCache();
     // Create test persons in database.
     // Tiny objects
     if (Person::CountAll() < $count) {
         for ($i = 0; $i < $count; $i++) {
             $objPerson = new Person();
             $objPerson->FirstName = 'FirstName' . $i;
             $objPerson->LastName = 'LastName' . $i;
             $objPerson->Save();
         }
     }
     // Bigger objects with expansion
     if (Project::CountAll() < $count) {
         for ($i = 0; $i < $count; $i++) {
             $objProject = new Project();
             $objProject->Name = 'Project' . $i;
             $objProject->ProjectStatusTypeId = ProjectStatusType::Open;
             $objProject->ManagerPersonId = $i % 1000 + 1000;
             $objProject->Description = 'Description' . $i;
             $objProject->StartDate = QDateTime::Now();
             $objProject->EndDate = QDateTime::Now();
             $objProject->Budget = $i;
             $objProject->Spent = 1;
             $objProject->Save();
         }
     }
     $this->pnlTiny = new QPanel($this);
     $this->pnlTiny->Name = '10,000 Person Objects';
     $this->pnlBig = new QPanel($this);
     $this->pnlBig->Name = '10,000 Project Objects With Expansion';
     $this->btnGo = new QButton($this);
     $this->btnGo->Text = 'Go';
     $this->btnGo->AddAction(new QClickEvent(), new QAjaxAction('Go_Click'));
 }
开发者ID:vaibhav-kaushal,项目名称:qc-framework,代码行数:38,代码来源:db_speed.php

示例3: isset

include_once '../Model/Person.php';
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$method = $_SERVER['REQUEST_METHOD'];
$format = isset($_REQUEST['format']) ? $_REQUEST['format'] : 'web';
$view = null;
switch ($action . '_' . $method) {
    case 'create_GET':
        $model = Person::Blank();
        $view = "persons/edit.php";
        break;
    case 'save_POST':
        $sub_action = empty($_REQUEST['id']) ? 'created' : 'updated';
        $errors = Person::Validate($_REQUEST);
        if (!$errors) {
            $errors = Person::Save($_REQUEST);
        }
        if (!$errors) {
            if ($format == 'json') {
                header("Location: ?action=edit&format=json&id={$_REQUEST['id']}");
            } else {
                header("Location: ?sub_action={$sub_action}&id={$_REQUEST['id']}");
            }
            die;
        } else {
            //my_print($errors);
            $model = $_REQUEST;
            $view = "persons/edit.php";
        }
        break;
    case 'edit_GET':
开发者ID:huili47,项目名称:2015FallWP,代码行数:30,代码来源:persons.php

示例4: btnCreate_Click

 public function btnCreate_Click($strFormId, $strControlId, $strParameter)
 {
     // Create a new person.
     $objPerson = new Person();
     $objPerson->FirstName = $this->objRegistrant->FirstName;
     $objPerson->LastName = $this->objRegistrant->LastName;
     $objPerson->Gender = $this->objRegistrant->Gender;
     $objPerson->PrimaryAddressText = $this->objRegistrant->Address;
     $objPerson->PrimaryCityText = $this->objRegistrant->City;
     $objPerson->PrimaryZipCodeText = $this->objRegistrant->Zipcode;
     $objPerson->PrimaryPhoneText = $this->objRegistrant->Phone;
     $objPerson->MembershipStatusTypeId = MembershipStatusType::NonMember;
     $objPerson->MaritalStatusTypeId = MaritalStatusType::NotSpecified;
     $objPerson->DeceasedFlag = false;
     $intPersonId = $objPerson->Save();
     $objEmail = new Email();
     $objEmail->Address = $this->objRegistrant->Email;
     $objEmail->PersonId = $intPersonId;
     $objEmail->Save();
     $this->intPersonId = $intPersonId;
     $pnlProjectView = new CpGroup_RegistrationStep2Panel($this->nextPanel, $this->objRegistrant, $this->intPersonId, $this->strMethodCallBack);
 }
开发者ID:alcf,项目名称:chms,代码行数:22,代码来源:CpGroup_RegistrationStep1Panel.class.php

示例5: GenerateIndividual

 /**
  * Generates a single Individual record
  * @param boolean $blnMaleFlag
  * @param boolean $blnAdultFlag whether this Individual should be a child or an adult
  * @param string $strLastName optional last name
  * @return Person
  */
 protected static function GenerateIndividual($blnMaleFlag, $blnAdultFlag, $strLastName = null)
 {
     $objPerson = new Person();
     $objPerson->Gender = $blnMaleFlag ? 'M' : 'F';
     // Generate the name
     $objPerson->FirstName = $blnMaleFlag ? QDataGen::GenerateMaleFirstName() : QDataGen::GenerateFemaleFirstName();
     switch (rand(1, 10)) {
         case 1:
         case 2:
         case 3:
             $objPerson->MiddleName = chr(rand(ord('A'), ord('Z'))) . '.';
             break;
         case 4:
         case 5:
             $objPerson->MiddleName = $blnMaleFlag ? QDataGen::GenerateMaleFirstName() : QDataGen::GenerateFemaleFirstName();
             break;
     }
     $objPerson->LastName = $strLastName ? $strLastName : QDataGen::GenerateLastName();
     $objPerson->CanEmailFlag = rand(0, 1);
     $objPerson->CanMailFlag = rand(0, 1);
     $objPerson->CanPhoneFlag = rand(0, 1);
     if (!rand(0, 10)) {
         $objPerson->Nickname = $blnMaleFlag ? QDataGen::GenerateMaleFirstName() : QDataGen::GenerateFemaleFirstName();
     }
     if (!rand(0, 5) && !$blnMaleFlag) {
         $objPerson->PriorLastNames = QDataGen::GenerateLastName();
     }
     if (!rand(0, 10)) {
         $objPerson->MailingLabel = QString::FirstCharacter($objPerson->FirstName) . '. ' . $objPerson->LastName;
     }
     if (!rand(0, 10)) {
         $arrTitleArray = $blnMaleFlag ? array('Mr.', 'Dr.', 'Sir') : array('Ms.', 'Miss', 'Mrs.', 'Dr.', 'Lady');
         $objPerson->Title = QDataGen::GenerateFromArray($arrTitleArray);
     }
     if (!rand(0, 10)) {
         $arrSuffixArray = array('Sr.', 'Jr.', 'III', 'PhD', 'MD');
         $objPerson->Suffix = QDataGen::GenerateFromArray($arrSuffixArray);
     }
     // Date of Birth
     if ($blnAdultFlag) {
         if (rand(0, 1)) {
             $objPerson->DateOfBirth = QDataGen::GenerateDateTime(self::$LifeStartDate, self::$OldestChildBirthDate);
         }
     } else {
         $objPerson->DateOfBirth = QDataGen::GenerateDateTime(self::$OldestChildBirthDate, QDateTime::Now());
     }
     if ($objPerson->DateOfBirth) {
         $objPerson->DobGuessedFlag = !rand(0, 12);
         $objPerson->DobYearApproximateFlag = !rand(0, 12);
     }
     // Refresh Membership and Marital Statuses
     $objPerson->RefreshMembershipStatusTypeId(false);
     $objPerson->RefreshMaritalStatusTypeId(false);
     $objPerson->RefreshAge(false);
     // Setup Deceased Information
     $objPerson->DeceasedFlag = !rand(0, 200);
     if ($objPerson->DeceasedFlag && rand(0, 1)) {
         $objPerson->DateDeceased = QDataGen::GenerateDateTime(self::$LifeStartDate, QDateTime::Now());
     }
     $objPerson->Save();
     $objPerson->RefreshNameItemAssociations();
     // Head Shots
     $objHeadShotArray = array();
     $intHeadShotCount = rand(0, 3);
     for ($i = 0; $i < $intHeadShotCount; $i++) {
         $objHeadShotArray[] = $objPerson->SaveHeadShot(self::GetRandomHeadShot($objPerson->Gender == 'M'), QDataGen::GenerateDateTime(self::$SystemStartDate, QDateTime::Now()));
     }
     if (count($objHeadShotArray)) {
         $objPerson->SetCurrentHeadShot(QDataGen::GenerateFromArray($objHeadShotArray));
     }
     // Membership
     $intMembershipCount = 0;
     if ($blnAdultFlag) {
         if (!rand(0, 2)) {
             $intMembershipCount = rand(1, 3);
         }
     } else {
         if (!rand(0, 10)) {
             $intMembershipCount = rand(1, 2);
         }
     }
     if ($intMembershipCount) {
         $dttEarliestPossible = new QDateTime($objPerson->DateOfBirth ? $objPerson->DateOfBirth : self::$SystemStartDate);
         self::GenerateMembershipsForIndividual($objPerson, $dttEarliestPossible, $intMembershipCount);
     }
     // Past or non-defined marriage
     if ($blnAdultFlag && !rand(0, 10)) {
         $objMarriage = new Marriage();
         $objMarriage->Person = $objPerson;
         $objMarriage->MarriageStatusTypeId = QDataGen::GenerateFromArray(array_keys(MarriageStatusType::$NameArray));
         if (rand(0, 1)) {
             $dttStart = QDateTime::Now();
             $dttStart = QDataGen::GenerateDateTime(self::$LifeStartDate, $dttStart);
//.........这里部分代码省略.........
开发者ID:alcf,项目名称:chms,代码行数:101,代码来源:datagen.cli.php

示例6: Person

<?php

// Require the person class file
require "Person.class.php";
// Instantiate the person class
$person = new Person();
// Create new person
$person->Firstname = "Kona";
$person->Age = "20";
$person->Sex = "F";
$creation = $person->Create();
// Update Person Info
$person->id = "4";
$person->Age = "32";
$saved = $person->Save();
// Find person
$person->id = "4";
$person->Find();
d($person->Firstname, "Person->Firstname");
d($person->Age, "Person->Age");
// Delete person
$person->id = "17";
$delete = $person->Delete();
// Get all persons
$persons = $person->all();
// Aggregates methods
d($person->max('age'), "Max person age");
d($person->min('age'), "Min person age");
d($person->sum('age'), "Sum persons age");
d($person->avg('age'), "Average persons age");
d($person->count('id'), "Count persons");
开发者ID:luokizz,项目名称:PHP-MySQL-PDO-Database-Class,代码行数:31,代码来源:index.php

示例7: CreatePerson

 /**
  * Given some very limited information, this will create a Person record for it
  * @param string $strFirstName
  * @param string $strMiddle
  * @param string $strLastName
  * @param boolean $blnMaleFlag
  * @param string $strEmail optional
  * @param string $strPhone optional
  * @param integer $intPhoneTypeId optional unless $strPhone has been specified
  * @param integer $intMobileProviderId optional
  * @return Person
  */
 public static function CreatePerson($strFirstName, $strMiddle, $strLastName, $blnMaleFlag, $strEmail = null, $strPhone = null, $intPhoneTypeId = null, $intMobileProviderId = null)
 {
     $strFirstName = trim($strFirstName);
     $strMiddle = trim($strMiddle);
     $strLastName = trim($strLastName);
     switch (strlen($strMiddle)) {
         case 1:
             $strMiddle = strtoupper($strMiddle);
             break;
         case 2:
             if (substr($strMiddle, 1, 1) == '.') {
                 $strMiddle = strtoupper(substr($strMiddle, 0, 1));
             }
             break;
     }
     $objPerson = new Person();
     $objPerson->FirstName = $strFirstName;
     $objPerson->MiddleName = strlen($strMiddle) ? $strMiddle : null;
     $objPerson->LastName = $strLastName;
     $objPerson->RefreshMaritalStatusTypeId(false);
     $objPerson->RefreshMembershipStatusTypeId(false);
     if (!is_null($blnMaleFlag)) {
         $objPerson->Gender = $blnMaleFlag ? 'M' : 'F';
     }
     $objPerson->DeceasedFlag = false;
     $objPerson->CanEmailFlag = true;
     $objPerson->CanPhoneFlag = true;
     $objPerson->CanMailFlag = true;
     $objPerson->Save();
     $objPerson->RefreshNameItemAssociations();
     // Create Primary Contact Info (if applicable)
     $blnSaveAgain = false;
     if ($strEmail) {
         $objEmail = new Email();
         $objEmail->Person = $objPerson;
         $objEmail->Address = $strEmail;
         $objEmail->Save();
         $objPerson->PrimaryEmail = $objEmail;
         $blnSaveAgain = true;
     }
     if ($strPhone) {
         $objPhone = new Phone();
         $objPhone->Person = $objPerson;
         $objPhone->PhoneTypeId = $intPhoneTypeId;
         if ($objPhone->PhoneTypeId == PhoneType::Mobile) {
             $objPhone->MobileProviderId = $intMobileProviderId;
         }
         $objPhone->Number = $strPhone;
         $objPhone->Save();
         $objPerson->PrimaryPhone = $objPhone;
         $blnSaveAgain = true;
     }
     if ($blnSaveAgain) {
         $objPerson->Save();
     }
     return $objPerson;
 }
开发者ID:alcf,项目名称:chms,代码行数:69,代码来源:Person.class.php

示例8: SetAsPrimary

 /**
  * This will set this phone object as the "primary" phone number for (if associated to an address) the address
  * or (if associated to a person) the person.
  * 
  * Alternatively, if the phone is associated with the address (e.g. a home phone), you can explicitly
  * pass in a Person in that house to set as "primary" for that person.
  * 
  * This will automatically UNSET as primary any current-primary phone (if applicable)
  * @return void
  */
 public function SetAsPrimary(Person $objPerson = null, Address $objAddress = null)
 {
     if ($objPerson) {
         if ($this->PersonId != $objPerson->Id && (!$this->Address || !$this->Address->Household || !HouseholdParticipation::LoadByPersonIdHouseholdId($objPerson->Id, $this->Address->HouseholdId))) {
             throw new QCallerException('Cannot set as primary phone for person not in the household for this address');
         }
         $objPerson->PrimaryPhone = $this;
         $objPerson->Save();
         $objPerson->RefreshPrimaryContactInfo();
     } else {
         if ($objAddress) {
             if ($objAddress->Id != $this->intAddressId) {
                 throw new QCallerException('Cannot set as primary phone for home address that does not own this phone object');
             }
             $objAddress->PrimaryPhone = $this;
             $objAddress->Save();
         } else {
             if ($this->Address) {
                 $this->Address->PrimaryPhone = $this;
                 $this->Address->Save();
             } else {
                 $this->Person->PrimaryPhone = $this;
                 $this->Person->Save();
                 $this->Person->RefreshPrimaryContactInfo();
             }
         }
     }
 }
开发者ID:alcf,项目名称:chms,代码行数:38,代码来源:Phone.class.php

示例9: 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

示例10: QDateTime

    $objPerson->Email = $objRow['email'];
    $objPerson->PasswordResetFlag = false;
    $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)) {
开发者ID:qcodo,项目名称:qcodo-website,代码行数:31,代码来源:migrator.cli.php


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