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


PHP Person::insert方法代码示例

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


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

示例1: testInsert

 public function testInsert()
 {
     $this->prepareDB(false);
     $oDriver = DBDriver::get_instance('sqlite', array('filename' => dirname(__FILE__) . '/unittest.db'));
     $oPerson = new Person();
     $oPerson->firstName = 'Jerome';
     $oPerson->lastName = 'Poichet';
     $mRes = $oPerson->insert($oDriver);
     $mRes = Person::select('Person')->where('firstName', 'Jerome')->exec($oDriver);
     $this->assertEquals(1, $mRes->numRows());
     $oOther = $mRes->fetch();
     $this->assertEquals('Person', get_class($oOther));
     $this->assertNotNull($oOther->id);
     $this->assertEquals($oPerson->id, $oOther->id);
 }
开发者ID:poitch,项目名称:dokin,代码行数:15,代码来源:SQLiteTest.php

示例2: run

 public function run()
 {
     $name = !empty($_POST['name']) ? $_POST['name'] : "";
     $email = !empty($_POST['email']) ? $_POST['email'] : "";
     $postalCode = !empty($_POST['cp']) ? $_POST['cp'] : "";
     $pwd = !empty($_POST['pwd']) ? $_POST['pwd'] : "";
     $city = !empty($_POST['city']) ? $_POST['city'] : "";
     //Get the person data
     $newPerson = array('name' => $name, 'email' => $email, 'postalCode' => $postalCode, 'pwd' => $pwd, 'city' => $city);
     try {
         $res = Person::insert($newPerson, false);
         Person::saveUserSessionData($res["id"], $email, array("name" => $name));
     } catch (CTKException $e) {
         $res = array("result" => false, "msg" => $e->getMessage());
     }
     Rest::json($res);
     exit;
 }
开发者ID:CivicTechFR,项目名称:PixelHumain,代码行数:18,代码来源:RegisterAction.php

示例3: actionInsertNewPerson

 public function actionInsertNewPerson()
 {
     $res = Person::insert(array('name' => "Test", 'email' => "new@email.com", 'postalCode' => "97426", 'pwd' => "vlanlepass"));
     var_dump($res);
 }
开发者ID:Biocoder2600,项目名称:communecter,代码行数:5,代码来源:TestController.php

示例4: testDeleteMultiple

 public function testDeleteMultiple()
 {
     $oDriver = DBDriver::get_instance('mongo');
     // Clean up database
     Person::delete('Person')->where('firstName', 'Jerome')->exec($oDriver);
     $iCount = 10;
     for ($i = 0; $i < $iCount; $i++) {
         $oPerson = new Person();
         $oPerson->firstName = 'Jerome';
         $oPerson->lastName = 'Poichet';
         $mRes = $oPerson->insert()->exec($oDriver);
     }
     $oRes = Person::select('Person')->where('firstName', 'Jerome')->exec($oDriver);
     $this->assertEquals($iCount, $oRes->numRows());
     Person::delete('Person')->where('firstName', 'Jerome')->exec($oDriver);
     $oRes = Person::select('Person')->where('firstName', 'Jerome')->exec($oDriver);
     $this->assertEquals(0, $oRes->numRows());
 }
开发者ID:poitch,项目名称:dokin,代码行数:18,代码来源:MongoTest.php

示例5: Person

 */
$person = new Person();
$person->name = "Frank Zappa";
$person->birthday = "1940-12-20";
$person->salary = 1000;
$person->insert();
echo SEPARATOR . "New person inserted:\n";
print_r($person);
/**
 * To create a Model from data contained in an array, use the merge() method to
 * overwrite any data in the model with the data from the array.
 */
$data = array('name' => 'Captain Beefheart', 'birthday' => '1941-01-15', 'salary' => 1200);
$person = new Person();
$person->merge($data);
$person->insert();
echo SEPARATOR . "New person inserted:\n";
print_r($person);
/**
 * To change an existing record, fetch it from the database, perform the
 * required changes and call update().
 */
$personID = $person->id;
echo SEPARATOR . "Person #{$personID} before changes:\n";
print_r(Person::get($personID));
// Get, change, update
$person = Person::get($personID);
$person->salary += 500;
$person->update();
echo SEPARATOR . "Person #{$personID} after changes:\n";
print_r(Person::get($personID));
开发者ID:Macavity,项目名称:phormium,代码行数:31,代码来源:models-write.php

示例6: testInsert

 function testInsert()
 {
     $people = Make::a('Person')->all();
     $people_count = count($people);
     $person = new Person();
     $person->firstName = 'Joe';
     $person->lastName = 'Biden';
     $person->age = 65;
     $person->insert();
     $people = Make::a('Person')->all();
     $this->assertEquals($people_count + 1, count($people));
 }
开发者ID:amitshukla30,项目名称:recess,代码行数:12,代码来源:ModelTest.php

示例7: createPersonOrganizationAndAddMember

 /**
  * When an initation to join an organization network is sent :
  * this method will :
  * 1. Create a new person and organization.
  * 2. Make the new person a member and admin of the organization
  * 3. Join the network of the organization inviting
  * @param type $person the minimal data to create a person
  * @param type $organization the minimal data to create an organization
  * @param type $parentOrganizationId the organization Id to join the network of
  * @return newPersonId ans newOrganizationId
  */
 public static function createPersonOrganizationAndAddMember($person, $organization, $parentOrganizationId)
 {
     //The data check is normaly done before inserting but the both data (organization and person)
     //must be ok before inserting
     //Check person datas
     Person::getAndcheckPersonData($person, false);
     //Check organization datas
     Organization::getAndCheckOrganization($organization);
     //Create a new person
     $newPerson = Person::insert($person);
     //Create a new organization
     $newOrganization = Organization::insert($organization, $newPerson["id"]);
     //Link the person as an admin
     Link::addMember($newOrganization["id"], Organization::COLLECTION, $newPerson["id"], PHType::TYPE_CITOYEN, $newPerson["id"], true);
     //Link the organization as a member of the invitor
     //TODO SBAR - On GRANDDIR case, the parent organization can manage (data, event, project...) their organization members.
     //Should be a parameter of the application.
     $isParentOrganizationAdmin = true;
     Link::addMember($parentOrganizationId, Organization::COLLECTION, $newOrganization["id"], Organization::COLLECTION, $newPerson["id"], $isParentOrganizationAdmin);
     return array("result" => true, "msg" => Yii::t("organisation", "The invitation process completed with success"), "id" => $newOrganization["id"]);
 }
开发者ID:CivicTechFR,项目名称:PixelHumain,代码行数:32,代码来源:Organization.php

示例8: actionInsertNewPerson

 public function actionInsertNewPerson()
 {
     $params = array('name' => "Test", 'email' => "new14@email.com", 'postalCode' => "97426", "city" => "97401", 'pwd' => "vlanlepass");
     $res = Person::insert($params);
     var_dump($params);
 }
开发者ID:zourite,项目名称:communecter,代码行数:6,代码来源:TestController.php


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