本文整理汇总了PHP中Person::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::update方法的具体用法?PHP Person::update怎么用?PHP Person::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person::update方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpdateCriteria
public function testUpdateCriteria()
{
$this->prepareDB(true);
$oDriver = DBDriver::get_instance('sqlite', array('filename' => dirname(__FILE__) . '/unittest.db'));
$mRes = Person::select('Person')->where('lastName', 'B')->exec($oDriver);
$this->assertEquals(1, $mRes->numRows());
$mRes = Person::update('Person')->set('lastName', 'Poichet')->where('lastName', 'B')->exec($oDriver);
$mRes = Person::select('Person')->where('lastName', 'B')->exec($oDriver);
$this->assertEquals(0, $mRes->numRows());
$mRes = Person::select('Person')->where('lastName', 'Poichet')->exec($oDriver);
$this->assertEquals(2, $mRes->numRows());
}
示例2: testUpdateWithExec
public function testUpdateWithExec()
{
$oDriver = DBDriver::get_instance('mongo');
Person::delete('Person')->where('firstName', 'Tadao')->exec($oDriver);
$oPerson = new Person();
$oPerson->firstName = 'Jerome';
$oPerson->lastName = 'Poichet';
$mRes = $oPerson->insert()->exec($oDriver);
$this->assertNotNull($mRes);
$this->assertNotNull($oPerson->_id);
$this->assertNotNull($mRes->_id);
// Update
$oPerson->firstName = 'Tadao';
$mRes = $oPerson->update()->exec($oDriver);
$this->assertNotNull($mRes);
$this->assertEquals('Tadao', $oPerson->firstName);
// Find back
$oRes = Person::select('Person')->where('firstName', 'Tadao')->exec($oDriver);
$oOther = $oRes->fetch();
$this->assertEquals($oPerson->_id, $oOther->_id);
$this->assertEquals('Tadao', $oOther->firstName);
$mRes = $oPerson->delete($oDriver);
$this->assertEquals(true, $mRes);
}
示例3: error_reporting
//
error_reporting(E_ALL);
ini_set('display_errors', true);
//
require_once '../data.php';
//
require_once '../../SchemaDB.php';
//
use SourceForge\SchemaDB\SchemaDB;
//
use SourceForge\SchemaDB\Storable;
//
new SchemaDB(array('host' => $host, 'user' => $user, 'pass' => $pass, 'name' => $name, 'pref' => $pref));
//
class Person extends Storable
{
//
public $id = self::PRIMARY_KEY;
//
public $name = "";
//
public $age = 0;
}
// update record with id=10
echo Person::update(10, array('age' => 21));
// update all record where age = 11
echo Person::update(array('age' => 11), array('age' => 21));
// update all record where age > 10
echo Person::update(array('where' => 'age > 10'), array('age' => 21));
示例4: switch
<?php
$action = $_REQUEST['action'];
$handler->loadModel('people_m');
$person = new Person;
switch ($action){
case 'read':
echo $person->read($_POST);
break;
case 'create':
echo $person->create($_POST);
break;
case 'update':
echo $person->update($_POST);
break;
case 'destroy':
echo $person->destroy($_POST['data']);
break;
case 'edit':
echo $person->edit($_POST['id'],$_POST);
break;
}
?>
示例5: Person
$person = new Person();
$data = array('name' => 'Tommy', 'age' => '20', 'citizenship' => 'American');
$person->bind($data);
$person->add();
// Select les users par l'âge et l'id
$person = new Person();
$person->age = '20';
// $person->id='558';
$personlist = $person->loadMultiple();
foreach ($personlist as $person) {
var_dump("{$person->name} {$person->age} {$person->citizenship} \r\n");
}
// Pour filtrer les recherches
$dbo->select('id', 'name', 'age')->from('person')->where('age=20')->limit(2)->result();
$personlist = $dbo->loadObjectList();
foreach ($personlist as $person) {
echo "<br><br>";
echo " Username: {$person['name']} <br> Age: {$person['age']} <br> Id: {$person['id']} ";
}
$dbo->orderby('id');
// Remplace le USER dans la base de données par un autre
$person = new Person();
$person->age = '20';
$person->load();
$data = array('name' => 'Laure-Ashley', 'age' => '21', 'citizenship' => 'french');
$person->bind($data);
$person->update();
//Supprimer un user par l'id
$person = new Person();
$person->id = '611';
$person->remove();
示例6: update
function update()
{
global $dbh;
$returnValue = false;
if (parent::update()) {
$query = '
UPDATE
`employeeDetails`
SET
`IDNumber`
, `KRAPIN`
, `dateOfEmployment`
WHERE
`uniqueID` = "' . mysql_escape_string($this->getUniqueID()) . '"';
try {
$statement = $dbh->prepare($query);
$statement->execute();
$returnValue = true;
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die;
}
$returnValue = true;
}
return $returnValue;
}
示例7: array
<?php
//
require_once 'common.php';
/*
* Update database record without load by id
\*/
// ---------
// WRONG WAY
// ---------
//
echo '<h2>WRONG WAY</h2>';
//
$Id = 1;
//
$Item = Person::load($Id);
//
$Item->age = 31;
//
$Item->store();
// ---------
// RIGHT WAY
// ---------
//
echo '<h2>RIGHT WAY</h2>';
//
$Id = 1;
//
Person::update($Id, array('age' => 31));
示例8: fixGenealogyDates
function fixGenealogyDates()
{
//Make a connection to the database
$recordsPerBatch = 10;
$startRecord = isset($_SESSION['genealogyDateFix']['currentRecord']) ? $_SESSION['genealogyDateFix']['currentRecord'] : 0;
$currentRecord = $startRecord;
$numRecords = $_SESSION['genealogyDateFix']['numRecords'];
//Get the next set of people to reindex
$person = new Person();
$person->limit($startRecord, $recordsPerBatch);
$person->find();
if ($person->N) {
while ($person->fetch() == true) {
//Check the dates to see if they need to be fixed
$dateUpdated = false;
if (isset($person->birthDate) && strlen($person->birthDate) > 0 && $person->birthDate != '0000-00-00') {
$dateParts = date_parse($person->birthDate);
$person->birthDateDay = $dateParts['day'];
$person->birthDateMonth = $dateParts['month'];
$person->birthDateYear = $dateParts['year'];
$person->birthDate = '';
$dateUpdated = true;
}
if (isset($person->deathDate) && strlen($person->deathDate) > 0 && $person->deathDate != '0000-00-00') {
$dateParts = date_parse($person->deathDate);
$person->deathDateDay = $dateParts['day'];
$person->deathDateMonth = $dateParts['month'];
$person->deathDateYear = $dateParts['year'];
$person->deathDate = '';
$dateUpdated = true;
}
//Update marriages
$marriages = $person->marriages;
$marriagesUpdated = false;
foreach ($marriages as $key => $marriage) {
$marriageUpdated = false;
if (isset($marriage->marriageDate) && strlen($marriage->marriageDate) > 0 && $marriage->marriageDate != '0000-00-00') {
$dateParts = date_parse($person->marriageDate);
$marriage->marriageDateDay = $dateParts['day'];
$marriage->marriageDateMonth = $dateParts['month'];
$marriage->marriageDateYear = $dateParts['year'];
$marriage->marriageDate = '';
$marriageUpdated = true;
}
if ($marriageUpdated) {
$marriages[$key] = $marriage;
$marriagesUpdated = true;
}
}
if ($marriagesUpdated) {
$person->marriages = $marriages;
$dateUpdated = true;
}
//Update obituaries
$obituaries = $person->obituaries;
$obituariesUpdated = false;
foreach ($obituaries as $key => $obit) {
$obitUpdated = false;
if (isset($obit->date) && strlen($obit->date) > 0 && $obit->date != '0000-00-00') {
$dateParts = date_parse($obit->date);
$obit->dateDay = $dateParts['day'];
$obit->dateMonth = $dateParts['month'];
$obit->dateYear = $dateParts['year'];
$obit->date = '';
$obitUpdated = true;
}
if ($obitUpdated) {
$obituaries[$key] = $obit;
$obituariesUpdated = true;
}
}
if ($obituariesUpdated) {
$person->obituaries = $obituaries;
$dateUpdated = true;
}
if ($dateUpdated) {
$person->update();
}
$currentRecord += 1;
}
}
$_SESSION['genealogyDateFix']['currentRecord'] = $currentRecord;
$moreData = $currentRecord < $numRecords;
if (!$moreData) {
//Optimize the solr core
$person->optimize();
}
return array('percentComplete' => floor($currentRecord / $numRecords * 100), 'moreData' => $moreData, 'currentRecord' => $currentRecord);
}
示例9: update
function update($returnType = RETURN_BOOLEAN)
{
global $dbh;
$query = '
UPDATE
`studentDetails`
SET
`schoolID` = "' . mysql_escape_string($this->getSchoolID()) . '"
, `dateOfAdmission` = "' . mysql_escape_string($this->getDateOfAdmission()) . '"
, `yearOfStudyAtAdmission` = "' . mysql_escape_string($this->getYearOfStudyAtAdmission()) . '"
, `gender` = "' . mysql_escape_string($this->getGender()) . '"
, `EntryScore` = "' . mysql_escape_string($this->getEntryScore()) . '"
WHERE
`uniqueID` = "' . $this->getUniqueID() . '"';
if ($returnType == 0) {
$returnValue = false;
if (parent::update()) {
try {
$statement = $dbh->prepare($query);
$statement->execute();
$returnValue = true;
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die;
}
}
} else {
$returnValue = $query;
}
return $returnValue;
}
示例10:
<?php
//
require_once 'common.php';
//
use Javanile\SchemaDB\Storable;
//
class Person extends Storable
{
//
public $id = self::PRIMARY_KEY;
//
public $name = '';
//
public $age = 0;
}
// update record with id=10
echo Person::update(10, ['age' => 21]);
// update all record where age = 11
echo Person::update(['age' => 11], ['age' => 21]);
// update all record where age > 10
echo Person::update(['where' => 'age > 10'], ['age' => 21]);
示例11:
<?php
//
require_once 'common.php';
//
Person::getDatabase()->transact();
//
$Persons = Person::update(['name', 'Address1' => Address::join('name')]);
//
if (assert()) {
Person::getDatabase()->commit();
} else {
Person::getDatabase()->rollback();
}
//
Person::dump($Persons);