本文整理汇总了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);
}
示例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;
}
示例3: actionInsertNewPerson
public function actionInsertNewPerson()
{
$res = Person::insert(array('name' => "Test", 'email' => "new@email.com", 'postalCode' => "97426", 'pwd' => "vlanlepass"));
var_dump($res);
}
示例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());
}
示例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));
示例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));
}
示例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"]);
}
示例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);
}